Need to trigger notification once when assignment group changes

sri vijaya
Tera Contributor

Hi

i need to trigger a notification through business rule when assignment group is one of US ER, US AR, US PR and once triggered when we changed assignment group between these three it should not trigger notification

and once changed from US Tier to either if these groups again it should trigger notification

so i have done scripting in business rule but however when changing between these groups the notifications still triggering, please help to resolve the issue

@Dr Atul G- LNG @Sandeep Rajput @SN_Learn 

FYI sys ids used in code

US ER-99cb7eb61b243300ce6996002d4bcb5e

US AR-ddcb7eb61b243300ce6996002d4bcb5f

US PR-55cb7eb61b243300ce6996002d4bcb5d

US Tier-d9cb7eb61b243300ce6996002d4bcb6f

 

Pasting the script here

 
(function executeRule(current, previous /*null when async*/) {
 
 
 
if((current.assignment_group =='99cb7eb61b243300ce6996002d4bcb5e' && (previous.assignment_group != 'ddcb7eb61b243300ce6996002d4bcb5f' || previous.assignment_group != '55cb7eb61b243300ce6996002d4bcb5d')) ||(current.assignment_group == 'ddcb7eb61b243300ce6996002d4bcb5f'&& (previous.assignment_group != '99cb7eb61b243300ce6996002d4bcb5e' || previous.assignment_group !='55cb7eb61b243300ce6996002d4bcb5d')) || (current.assignment_group=='55cb7eb61b243300ce6996002d4bcb5d' && (previous.assignment_group != 'ddcb7eb61b243300ce6996002d4bcb5f' || previous.assignment_group != '99cb7eb61b243300ce6996002d4bcb5e'))){
gs.eventQueue('sn_hr_core.CasePrep',current,gs.getUserID());
 
}
 
 
else if(previous.assignment_group == 'd9cb7eb61b243300ce6996002d4bcb6f' && current.assignment_group == '99cb7eb61b243300ce6996002d4bcb5e'){
gs.eventQueue('sn_hr_core.CasePrep',current,gs.getUserID());
 
 
}
else if(previous.assignment_group == 'd9cb7eb61b243300ce6996002d4bcb6f' && current.assignment_group == 'ddcb7eb61b243300ce6996002d4bcb5f'){
gs.eventQueue('sn_hr_core.CasePrep',current,gs.getUserID());
 
 
}
else if(previous.assignment_group == 'd9cb7eb61b243300ce6996002d4bcb6f' && current.assignment_group == '55cb7eb61b243300ce6996002d4bcb5d'){
gs.eventQueue('sn_hr_core.CasePrep',current,gs.getUserID());
 
 
}
 
 
// Add your code here
 
})(current, previous);
1 ACCEPTED SOLUTION

Mark Manders
Mega Patron

I wasn't asked, but still my two cents: I think the issue is in your or conditions against the 'is not'. These will always return true. If "A is not 1 OR A is not 2" it will return true on 1 (because it is not 2) and on 2 (because it is not 1) and on 3 (because it is neither). Replace your 'ors' (||) with 'ands' (&&) and I think it will work, assuming the sys_id's are all correct and you have put all the possible transitions in there.

 

EDIT: just the 'ors' within the brackets of course, not in between them.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

View solution in original post

2 REPLIES 2

Mark Manders
Mega Patron

I wasn't asked, but still my two cents: I think the issue is in your or conditions against the 'is not'. These will always return true. If "A is not 1 OR A is not 2" it will return true on 1 (because it is not 2) and on 2 (because it is not 1) and on 3 (because it is neither). Replace your 'ors' (||) with 'ands' (&&) and I think it will work, assuming the sys_id's are all correct and you have put all the possible transitions in there.

 

EDIT: just the 'ors' within the brackets of course, not in between them.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

sri vijaya
Tera Contributor

Hi @Mark Manders 

This worked for me

and in the same business rule i need to add in the script if additional comments or work notes are updated, notification should not trigger, so can i do in the same script?