How to write an advanced condition for "Who will receive" user, not current user?

0rland0h
Kilo Explorer

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!

7 REPLIES 7

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.


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.


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