advance condition in notification improvement

avinashdubey103
Tera Guru

Hi ,

I have written a script to trigger the notifications.

Even after getting true the notification is not triggering: 

 

Script:

//Added as a part of story ITS-4961
//sys_id of catalog item "Workstation upgrade" and "Hardware allocation"

if (current.cat_item == '8ca422836f04b1009431be3' || current.cat_item == '9e2f7d7d6f2382009431be4447') {
    if ((current.cat_item == '8ca422836f04b1bb3ee4a3' && current.variables.u_upgrade_reason == 'PMI') || (current.cat_item == '9e2f7d7d6f31be4dbb3ee447' && current.variables.u_new_allocation_reason == 'PMI')) {


        answer = false;
    }
} else {

    var catalogItemId = current.cat_item.toString();
    gs.log("aDDTIONAL C1" + catalogItemId);
    var checker = new displayRitmVariables();
    var isItemExcluded = checker.isCatalogItemExcluded(catalogItemId);
    gs.log("aDDTIONAL C1 2" + isItemExcluded);
    if (isItemExcluded) {
        answer = false;
        gs.log("aDDTIONAL C1 3" + answer);
    } else {
        answer = true;
        gs.log("aDDTIONAL C1 4" + answer);
    }
}
gs.log("aDDTIONAL C1 5" + answer);

 

 

avinashdubey103_0-1713160177346.png

 

2 REPLIES 2

Nick Parsons
Mega Sage

I assume this script is part of the When to send tab's advanced condition? Is there something that's making you think the script is causing the email not to send? If the script is setting answer to true, then the script condition is satisfied. There must be something else that's not satisfied. Here are some things to check:

  • You're passing the filter in the Condition field
  • The recipient of the email is an active user in ServiceNow (ie: ensure there isn't an account for the email address you're sending to that is inactive)
  • The email your sending to is a valid email address
  • If Send to event creator is NOT checked, then the user that triggers the notification won't be the one who will receive the notification.
  • Check that it's not appearing in sys_email_log table and being set to sent-ignored (it could be set to this because there is an email with a matching condition that has a higher weight). If your email has a weight of 0 this shouldn't be the cause. 
  • Your notification recipients must have the appropriate notification preferences enabled.

    If the notification is subscribable, each ServiceNow user or group member must have the notification and channels (devices) for the notification enabled in their notification preferences. Admins can impersonate users to review and configure their notification preferences

MichalL
Kilo Expert

In addition to what Nick posted - I would also check if notification device was added for a user and is active.

Also, please try triggering notification again and see in events log if notification_engine_process event was created for the record (unless it's event based notification, then look for this particular event instead of the one I mentioned).

Hope this helps your investigation.

Michal Lewandowski