Can I prevent notifications from going to recipients when they come on duty (i.e., if they are not currently on duty)?

Yes; this requires a change to the Action Script. Note that the following steps are based on the "default" Event Domain; you will need to carry out these steps on your domain.

To make the required script change:

  1. Open the xMatters Developer IDE.
  2. Check out your Domain Script (e.g., default).
  3. Navigate to Process/Initial.
  4. Scroll down until you see the following section, add the bold text, and then save the script package:
IF (EXISTS($event.debug))  
 @script::log($event.incident_id & ": Ignoring Unknown filter Type:" & $filter)  
 ENDIF  
 ENDIF  
ENDFOR  
  
#######################  
# Changed by xMatters  
$no_recipients = true  
 FOR( $recipient : $event.recipients )  
 @result = @event::isAnyRecipientNotifiable($recipient)  
 IF ($result.recipientNotifiable)  
 IF (!empty($recipient))  
 @alert::link($recipient)  
 $no_recipients = false  
 ENDIF  
 ELSE  
 @script::log("Recipient: " & $recipient & " Not Notifiable, skipping recipient.")  
 ENDIF  
 ENDFOR  
  
 IF( $no_recipients )  
 @script::log("Nobody was notifiable, skipping notification.")  
 @event::terminate()  
 ELSE  
 @alert::performNotification()  
 ENDIF  
 # changed end   
######################  
  
$subscriptionList = @event::getSubscriptions()  
FOR ($subscriptionId : $subscriptionList )  

This updated script does the following:

  1. Takes the recipients list (in this case the list of three Groups) and loops through each recipient/Group.
  2. If the recipient/Group is notifiable (i.e., On Duty), link the recipient/Group to the alert.
  3. If the recipient/Group is not notifiable (i.e., not On Duty), skips this recipient and logs this information.
  4. Once all notifiable recipients are linked, performs the notification.
  5. If there are no notifiable recipients, terminates the event. 

The result is that only Groups currently on duty will be notified for this event; off-duty Groups will never be notified as they are not linked to the alert.

Note

When customizing Action Script Packages for integrations, take into account that the initial script often already links all event recipients. If this is the case, the above code will not work properly.

For the code customization to work properly, remove or comment out the following code from the initial script:

# link the notifiable recipients  
@alert::link( $event.recipients )  

This will allow the customized code to handle the recipients properly.

As an alternative, you could make the existing logic more concise and remove logging duplicates by combining the custom code with the following:

# Determine if there are any notifiable recipients and link them.  
IF ( ! EXISTS( $event.recipients ) )  
 $no_recipients = true  
 $message_note = "No Recipients exist for this event."  
 IF ( $main.debug )  
 @script::log( $main.log_prepend & $message_note )  
 ENDIF  
 @event::report( $message_note )  
ELSE  
 # Check if the recipients are notifiable.  
 @checkRecipient = @event::isAnyRecipientNotifiable( $event.recipients )  
 IF ( ! $checkRecipient.recipientNotifiable )  
 $no_recipients = true  
 $message_note = "None of the targeted Recipients were Notifiable, Reason: " & $checkRecipient.reason  
 IF ( $main.debug )  
 @script::log( $main.log_prepend & $message_note )  
 ENDIF  
 @event::report( $message_note )  
 ELSE  
 # link the Notifiable Recipients  
 @alert::link( $event.recipients )  
 $no_recipients = false  
 ENDIF  
ENDIF  

xMatters Reference

JDN-1056 Originally created by Don Clark

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk