Email notification condition on who receives an email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2015 11:31 AM
Under an email notification of mine, I want to script a condition that will control who will receive the email, not a condition to control when it will send.
My email recipients are currently dynamic from fields on my Request form, Requested By (custom) and Client. In my situation, I want this Request notification email to only go to the username in the "Requested By" field if there are not part of a certain user group (IT ServiceDesk). If they are part of the IT ServiceDesk group as "Requested By", there is simply no reason why they would need to receive this Request opened notification email (due to them already logging it, they'd know about the request).
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2015 12:18 PM
You could do the condition this way...
gs.getUser().isMemberOf("Group Name");
Getting a User Object - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2015 12:37 PM
I must have originally misunderstood, because I was trying to do this via the condition builder. What would be the full script structure required by doing it from Advanced Conditions?
If (gs.getUser().isMemberOf("IT ServiceDesk") = "true"{
answer = true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2015 01:09 PM
ismemberOf() returns true/false so you don't have to do the = "true" part. And you don't use if/then in a condition. The condition itself is the if part. Just put the following in the condition script:
gs.getUser().isMemberOf("IT ServiceDesk");
I assume you have other conditions so you'll have to add them to that, for example...
gs.getUser().isMemberOf("IT ServiceDesk") && current.somefield == "somevalue" && etc....
EDIT: you may be right that the advanced condition script requires the full if/then...return syntax, there are places where this isn't necessary so I may be crossing my wires
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2015 01:57 PM
I believe the 'If' is required because 'answer' has to equal true in the condition...
Just looking at this: Email notification advanced condition script to be combined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2015 02:11 PM
So it would be...
If (gs.getUser().isMemberOf("IT ServiceDesk") && ...other conditions...) {
answer = true;
}