How to stop a notification from sending for a specific group

Joshua Comeau
Kilo Sage

Looking for someone to share a working code

current configuration:

1st notification: (dont send this one if it is the group)

JoshuaComeau_0-1705427136156.png

 

2nd notification (send this one if its that group)

 

JoshuaComeau_1-1705427212282.png

 

 

 

 

1 ACCEPTED SOLUTION

So if this will not work

if(!current.group && !current.group.assignment_group && current.group.assignment_group != "ec711d8d1b0921904d480d01cd4bcb11") {
     answer = true
} else {
    answer = false
}

 

Then you need to look at it from the perspective of what data do you have.

You know the approval record.

That means you know the requested item.

Which means you know the catalog item.

Since you know the catalog item you know the workflow

Since you know the workflow you know how it decides the group.

Which means you just need to duplicate that decision making process into your script so you can generate the same group and then check that value for the one you would like to avoid.

 

So if the simple if statement above will not work then your script needs to get a lot more complicated.

 

View solution in original post

18 REPLIES 18

Well the code worked I just had to flip the true and false for the notifications but I do believe that also might be the better code

Actually I think flipping the true and false is better idea then switching && to ||.

 

😉

@DrewW would this be how to stop it via multiple groups? 

if (!current.group && !current.group.assignment_group && current.group.assignment_group != "ec711d8d1b0921904d480d01cd4bcb11, 05d5c1011b052190e010dd3bdc4bcb92, 78c15dcd1b0921904d480d01cd4bcb16, 98f151011b4921904d480d01cd4bcb81, 99b0514d1b0921904d480d01cd4bcb8c, b71299011b4921904d480d01cd4bcb3d, ec4601c11b052190e010dd3bdc4bcb77, f001dd4d1b0921904d480d01cd4bcbd0") {
    answer = true;
} else {
    answer = false;
}

the workflow uses an approval group:
EX of RITM

JoshuaComeau_0-1705431471037.png

 

I wrote this code but unsure if this will work:

var approvalRecord = new GlideRecord('sysapproval_group');
if (approvalRecord.get(current.sysapproval)) {
// Get the assignment group of the current approval
var assignmentGroup = approvalRecord.assignment_group.getDisplayValue();
if (assignmentGroup == 'ec711d8d1b0921904d480d01cd4bcb11') {
answer=true;
}
else answer=false;
}