How to add a condition from another table for email notifications

NFGDom
Mega Sage

Hello!

Under System Notification -> Email -> Notifications I'm looking at the OOTB Incident Resolved notification.

find_real_file.png

And its default condition is to send when Incident State changes to Resolved.

find_real_file.png

I'd like to add an and condition that checks to see if the incident has any Requests (sc_request) related to it. If it has a request, do not send notification. If it does not have a request, send the notification.

From what I can tell, when I click create request within the incident in the hamburger menu, it sets the incident as parent on the request. Not on the incident.

I unfortunately do not know at this time how to make an advance condition with scripting. Also when showing related fields, I did not see anything related to the request table.

Any help would be appreciated!

Thanks!
Dom

1 ACCEPTED SOLUTION

Strange, well some other OOB ones don't include the answer variable you could try this instead:

var g = new GlideRecord('sc_request'); 
g.addQuery('parent', current.sys_id); 
g.query();
if(g.hasNext()) {
   false;
} else {
	true;
}

View solution in original post

8 REPLIES 8

It didn't create the notification when the incident had a request, which is what was expected. However it didn't create a notification when the incident didn't have a request - still want it to be sent in this second case. I'll see if I can play around with it and continue to test.

Strange, well some other OOB ones don't include the answer variable you could try this instead:

var g = new GlideRecord('sc_request'); 
g.addQuery('parent', current.sys_id); 
g.query();
if(g.hasNext()) {
   false;
} else {
	true;
}

@Michael Ritchie Thank you! Tested this out and it worked as expected. Notification is not sent if there is a SC Request that has the Incident as a parent. Otherwise notification is sent. Appreciate the help!

Sukhbir Singh2
Giga Guru

Try this ....

var gr = new GlideRecord("sc_request");

gr.addQuery('parent', current.sys_id);

gr.addActiveQuery();

gr.query();

answer = gr.getRowCount()>0 ? false:true;