- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2020 09:12 AM
Hello!
Under System Notification -> Email -> Notifications I'm looking at the OOTB Incident Resolved notification.
And its default condition is to send when Incident State changes to Resolved.
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2020 02:02 PM
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;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2020 10:51 AM
Try something like:
var flag = true;
var g = new GlideRecord('sc_request');
g.addQuery('parent', current.sys_id);
g.query();
if(g.hasNext()) {
flag = false;
}
return flag;
Please mark this as helpful/correct if it answered your question!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2020 11:05 AM
Elijah's script will work but not knowing additional details like if you do want to send the notification IF the request is closed then you can add additional logic to the query:
var flag = true;
var g = new GlideRecord('sc_request');
g.addQuery('parent', current.sys_id);
g.addQuery('active', true);
g.query();
if(g.hasNext()) {
flag = false;
}
return flag;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2020 12:09 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2020 12:55 PM
I just looked at other out of the box notifications that have advanced scripts and they are all using the "answer" variable. Use this script instead:
answer = true;
var g = new GlideRecord('sc_request');
g.addQuery('parent', current.sys_id);
g.query();
if(g.hasNext()) {
answer = false;
}