Modifying Script Packages for Subscriptions
Each Event Domain has a separate Script Package that must be configured to handle Subscriptions. Use the xMatters Developer IDE to configure a Script Package (for more information on using the Developer IDE, refer to the xMatters Online Developer's Guide ).
To enable Subscriptions in a Script Package:
- Using the xMatters Developer IDE, check out the Script Package for the selected Event Domain.
- The “default” Script Package is configured to handle subscriptions out-of-the-box; no changes are necessary if you are using the “default” Event Domain.
- Add the following section to the “PROCESS - initial” script, immediately after the @alert::performNotification() method:
#added for subscriptions handling
$subscriptionList = @event::getSubscriptions()
FOR ($subscriptionId : $subscriptionList )
@subscription = @event::getSubscription($subscriptionId)
@subscriptionAlert = @subscription::notification()
@subscriptionAlert::setHandlerScript("response")
@subscriptionAlert::setPresentationScript("messaging")
@subscriptionContent = @subscription::content()
$subscriptionContent.message = "undefined"
if (EXISTS($subscriptionContent.choices))
$main.subscriptionChoices = $subscriptionContent.choices
endif
@subscriptionAlert::setContent(@subscriptionContent)
@subscriptionAlert::performNotification()
ENDFOR
- Ensure the “response” handler script exists and is configured to handle the responses defined in the two-way responses section of the Subscription.
- Any handler script can be used for this purpose, as long as the @subscriptionAlert::setHandlerScript() method is calling the correct script.
- Ensure the “messaging” presentation script exists and generates the correct content.
- Any presentation script can be used for this purpose, as long as the @subscriptionAlert::setPresentationScript() method is calling the correct script.
- Check in the modified Script Package as a production version.