Override Recipient for notification

Not Yet Reviewed

Is it possible to change or override the recipient for an alert in the action scripts.

OR does this user recipient has to come from the alert source itself..



Date Votes

Please sign in to leave a comment.

  • Hey John,
    Check out the (@notification::link(list recipients[, String delimiter]))[https://help.xmatters.com/devguide/#scriptingreference/scriptobjects/notificationobjectmethods/notification_link.htm%3FTocPath%3DScripting%2520Reference%7CScript%2520Objects%7CNotification%2520Object%7C____12] method. This is what actually attaches the recipients to the notification (and thus the event). So in your initial script you should see a line similar to this:

    @notification::performNotification ()

    $event.recipients is just an array with the incoming recipients, so you can manipulate it as you choose.
    I hope that helps!
    --- Travis

  • 0
  • Travis, i tried using below function , but was not successful.
    can you show me with an example, if i have to use "user1" as recipient

    i get below error when i use below fucntion

    2015/06/25 11:31:02.156

    Starting Notification(s)

    Starting Event 7,486,013, for incident INCIDENT_ID-7486013, and domain Webench

    Creating Notification(s)
    11:31:02.428 User

    Notifying John Pereira (a0393614)
    11:31:02.521 User

    John Pereira (a0393614) - An empty message cannot be sent; Notification will be discarded
    11:31:02.523 User

    John Pereira (a0393614) - John Pereira - Cell Email is inactive
    11:31:02.523 User

    John Pereira (a0393614) - John Pereira - Cell Phone 2 is inactive
    11:31:02.523 User

    John Pereira (a0393614) has 2 notifiable Device(s)
    11:31:02.524 User

    John Pereira (a0393614) has no notifiable Devices after applying filter BlackBerry,Test Pager,Second Oncall Cell,First Oncall Cell,First Oncall Pager,test sms phone,User Pager,Personal Cell Page,User Cell Pager,Second Oncall Pager

  • Ah, sorry. You'll have to track down the actual variable name of the "notification" object. It will be the same object that has the "performNotification" method attached.

  • Oh, to answer your question, assuming notification is the name of your notification object, it should be:

    $userList = "user1"
    @notification::link( $userList )

  • Travis, Can we also use a group name instead of user in same context..

  • Yep. Recipients for xMatters are users, groups or devices. It is smart enough to figure out which.

  • Travis, I got this to work, thanks for the guidance.

    while i got everything to work, i lost another thing , ie the $content.choices

    these dont seem to work in intital script, any workaround for this..

  • Hmmm, that is strange, that shouldn't happen. Those should be separate items. You can add "debug" statements by using the @event::report( "My message here" ) to print information at various points in the initial script. The parser is rather simple, so I think you might have to set the string before you actually log it:

    $str = "Content choices: " & $content.choices
    @event::report( $str )

  • thanks Travis, will try this out and let you know..

  • Travis, do you know if i can add user2,user3 to the $userList variable

    $userList = "user1"
    @notification::link( $userList )

  • Hey John, Yep, you can use the "add" operator:

    $userList = "user1"
    $userList::add( $newUser1 )
    $userList::add( "hard coded user here" )
    @notification::link( $userList )

    Per the docs, every object in the script is actually a single element list, so you can just do add on the list of one element to add another entry.

  • thanks, the add operator worked well.

    however i have another issue.

    i declared the userList in the initial action script with 2 users.
    now when i want to obtain the variable value in presentation script ,i cant seem to get the value.

    basically , if a=b, then i set userList to user1 and user2.
    then in presentation script, if userList is user1 and a=b , then do first thing
    else if userList is user2 and a=b, then do second thing

    i cant seem to get the value of userList in presentation script.

    if i try to log it, i get blank value

    how do i get the userList value accessible in another action script

  • Hey John,
    For printing lists, you have to use the toFormattedString method; the language doesn't automatically cast to strings very well.

    I'm not sure I understand the rest of your question. You mention "if userList is user1" are you looking to test if userList contains user1, or to test if there is only one value in the list?
    You can see all the available methods on Lists here. ANd you can see there is a contains method that might help you.


Didn't find what you were looking for?

New post