The Now Platform® Washington DC release is live. Watch now!
03-27-2023 08:58 PM - edited 03-27-2023 09:02 PM
Can anyone help me in getting the solution @priyasunku @Ankur Bawiskar @BharathChintala @Sumalatha Y @AnveshKumar M @Allen Andreas @asifnoor @Brad Tilton @Pradeep Sharma @Sonu Parab @Sandeep Dutta @Hemant Goldar @Mohit Kaushik
when Request is Cancelled Send notification to Requester, Assigned to & Approver (if Request is required for Approval).
I had written Notification, Created Event & written Business Rule but it's not triggering notification.
Notification:
Event:
Business Rule:
Solved! Go to Solution.
03-27-2023 09:24 PM
Hi @Arjun Reddy Yer ,
Remove recipients added in "Who will receive" section and check "event param1 contains recipients" as true. And use below code in business rule.
(function executeRule(current, previous /*null when async*/) {
var arr=[];
arr.push(current.requested_for.toString());
arr.push(current.assigned_to.toString());
var approval=new GlideRecord('sysapproval_approver');
approval.addQuery('sysapproval',current.sys_id.toString());
approval.query();
while(approval.next()){
arr.push(approval.approver.toString());
}
gs.eventQueue('sc_req_item.canceled',current,arr.toString());
})(current, previous);
03-27-2023 09:25 PM - edited 03-27-2023 09:28 PM
Hi @Arjun Reddy Yer ,
The issue is with your BR condition, you should keep it as "Stage changes to Closed complete OR stage changes to Request Canceled".
You are using "and" condition instead.
ALso the eventQueue function the params are very critical, for your case it should be something like:
gs.eventQueue('sc_req_item.canceled',current, current.assigned_to,childAssignedTo.string());
And also mark event parm 1 contains recipients and 2 in the notification
03-27-2023 09:24 PM
Hi @Arjun Reddy Yer ,
Remove recipients added in "Who will receive" section and check "event param1 contains recipients" as true. And use below code in business rule.
(function executeRule(current, previous /*null when async*/) {
var arr=[];
arr.push(current.requested_for.toString());
arr.push(current.assigned_to.toString());
var approval=new GlideRecord('sysapproval_approver');
approval.addQuery('sysapproval',current.sys_id.toString());
approval.query();
while(approval.next()){
arr.push(approval.approver.toString());
}
gs.eventQueue('sc_req_item.canceled',current,arr.toString());
})(current, previous);
03-27-2023 09:37 PM
Need to create Async Business Rule with the script that you had mentioned
(function executeRule(current, previous /*null when async*/) {
var arr=[];
arr.push(current.requested_for.toString());
arr.push(current.assigned_to.toString());
var approval=new GlideRecord('sysapproval_approver');
approval.addQuery('sysapproval',current.sys_id.toString());
approval.query();
while(approval.next()){
arr.push(approval.approver.toString());
}
gs.eventQueue('sc_req_item.canceled',current,arr.toString());
})(current, previous);
03-27-2023 09:42 PM
You can create After or Async with required conditions.
03-27-2023 09:50 PM
Can you help me on issue which I'm facing https://www.servicenow.com/community/developer-forum/is-it-possible-via-workflow-to-auto-change-the-...