Disabling Certain Notifications from Workflow

jmiskey
Kilo Sage

I am working on a Workflow from a Service Catalog Request that creates a Requested Item.   Currently, the workflow generates 10 notifications.   Some of these are from Notification actions, some are from other actions (like Tasks) and others are automated notifications (like changes in Stages, verification of submission, completion, etc).  

The team that is making this request would like to change some of the wording on the Notifications to include more information (mostly catalog variables).   For the Notification actions and Task actions, this is easy enough to do, but the issue is with the automatic notifications.   Is it possible just to suppress some of those, so I can manually create new Notification actions?   Or is it an "all or nothing" proposition, where I can only suppress all automated notifications, or allow all?   And, is there any guide to identify each of these automated notifications?

Thanks

1 ACCEPTED SOLUTION

I found the answer I need!   It is to use the Advanced Script in the Notification in this post from Michael Ward: Re: Disable Request opened/approved emails



(copied from his post so that the answer is in this thread:



var gr = new GlideRecord('sc_req_item');


gr.addQuery('request',current.sys_id);   // current is the sc_request


gr.addQuery('cat_item','<a catalog item sys_id>'); // perhaps set to a sys_property


gr.query();


if (gr.next()) {


  answer=false;


} else {


  answer=true;


}



So, I just go the sys_id from the Catalog Item and substituted it in the code, and it worked like magic!


View solution in original post

9 REPLIES 9

Nate23
Mega Guru

ahh I was thinking the request item table, my apologies.


I found the answer I need!   It is to use the Advanced Script in the Notification in this post from Michael Ward: Re: Disable Request opened/approved emails



(copied from his post so that the answer is in this thread:



var gr = new GlideRecord('sc_req_item');


gr.addQuery('request',current.sys_id);   // current is the sc_request


gr.addQuery('cat_item','<a catalog item sys_id>'); // perhaps set to a sys_property


gr.query();


if (gr.next()) {


  answer=false;


} else {


  answer=true;


}



So, I just go the sys_id from the Catalog Item and substituted it in the code, and it worked like magic!


I'm suuuper new to SN, and was looking at this solution for the same exact problem I have. Could you explain this code a bit? 

Would that work for a Notification set before a Catalog Task in a request item workflow? Or would you have to change sc_req_item to sc_task? 

Can you explain each line if it's not too much trouble? I don't have any experience with the advanced option on Notifications, or scripting in SN

 

Thanks in advance!

I'm suuuper new to SN, and was looking at this solution for the same exact problem I have. Could you explain this code a bit? 

Would that work for a Notification set before a Catalog Task in a request item workflow? Or would you have to change sc_req_item to sc_task? 

Can you explain each line if it's not too much trouble? I don't have any experience with the advanced option on Notifications, or scripting in SN

 

Thanks in advance!

If you are going to do any scripting in ServiceNow, you are going to need to learn JavaScript.  That is what most of this code uses.  Without understanding that, it will be hard to understand any of the code.

Here is a good on-line tutorial that can help you learn JavaScript (I used it myself):

https://www.w3schools.com/js/default.asp

The code used in this thread is a "GlideRecord Query".  To see how to structure these, from a ServiceNow vantage point, see this link here: https://docs.servicenow.com/bundle/orlando-application-development/page/script/server-scripting/conc...

That explains each of the components of it.