How to write an advanced condition for "Who will receive" user, not current user?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2016 02:14 PM
Trying to find out how to write an advanced condition that will check for the user that is under, 'Who will receive" and not the current user that is triggering an incident. I am trying to write a blackout period for the user of Who will receive section, to NOT receive an email from a set period of time. I have currently written a script that will trigger based on roles, which is what we would probably end up doing.
This is what I currently have:
var currentUser = gs.getUser();
if(currentUser.hasRole('enter any role here.')){ //you can insert admin role or itil role and it runs as expected
var n = new Date().getHours();
gs.log('This is what n is going to be');
if(n >= 14 && n <= 15){ //based on a 24 hour clock
gs.log('This is true!'); //logging for the purposes of tracking the variables.
answer = true;
}
else{
gs.log('This is not running as intended');
answer = false;
}
}
else
{
gs.log("This didn't run period!!!!! ")
answer = false;
}
What I need to be able to include in this, is the "Who will receive" user. I do not need the user that is triggering the event to not be able to trigger this condition. We have other notifications that will trigger that rule.
Any suggestions? Any clarifications can be answered as well.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2016 12:21 PM
I'll take a look at this, I believe I have seen this before and should look into more to see if what I need is in it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2016 04:50 PM
Is this notification triggered by an event? If so you could possibly implement the logic on who gets the notification in the code that generates the event, and pass the recipient/s through (or not), as event parameters as Lauren suggested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2017 01:33 PM
The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here: Scripting for Email Notifications
Visit http://docs.servicenow.com for the latest product documentation