Sometimes you want to ack or close an alarm due to some condition like a dataitem value. The actions in an expression rule pertain to the event that triggered the expression rule, so calling SetAlarmState doesn't work because it acts on the alarm that caused the rule to run.
A rule like this runs a script a dataitem called machine.state has a value 0
IF machine.state == 0
THEN ExecuteCustomObject("CloseAlarms")
The script CloseAlarms gets an AlarmFinder and then loops through all alarms, setting their state to closed. The logic could be changed to find a single named alarm or alarms with a pattern by calling setAlarmName (which takes a String for exact match, or a StringQuery for pattern matching). This script uses the implicit parameter context.device to get the current device, and also shows the use of logger.info to print out debug messages.

