Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Eliminate the OOB Approval rejected email notifications for a specific catalog item

Cupcake
Mega Guru

We have 3 Approval Rejected Email Notifications that I don't want to go out if it is for a specific catalog item. I put the script in all 3 and it seems to be working fine, but then only to discover that by having the script in all 3 it is not sending the emails if any other catalog item has been rejected. Not sure why Approval Rejected 2 is giving me such a headache.

Any ideas?

Here is the script that I have inside of the notification

answer = true;
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
if (gr.next()) {
if (gr.cat_item.sys_id == "b5f2537d0fb6d700fbe937f692050e2d" ) 
answer = false;
else
answer = true;
}

Issue: By having the script in all 3 notifications, it will not fire the rejection emails for any catalog item. If I remove the script from the Approval rejected 2 email it works just fine for everything (but the problem here is it is still going out for the specific catalog item) and I don't want that. Not sure why only that notification is giving me a problem.

 Here are the 3 email notifications

find_real_file.png

 

These notifications all sit on the approval table

find_real_file.png

 

 

 

 

1 ACCEPTED SOLUTION

Loudigi
Kilo Sage

 I'm not sure that you need to do a query. 

Try this:

answer = true;

if (current.sysapproval.cat_item == "b5f2537d0fb6d700fbe937f692050e2d" ) {
answer = false;
}else
answer = true;

View solution in original post

2 REPLIES 2

Loudigi
Kilo Sage

 I'm not sure that you need to do a query. 

Try this:

answer = true;

if (current.sysapproval.cat_item == "b5f2537d0fb6d700fbe937f692050e2d" ) {
answer = false;
}else
answer = true;

Thank you much. This worked perfectly no query needed.