Previous Approvers need to copied on workflow servicenow

Are Kaveri
Tera Contributor

Need help for below requirement..

 

i have configured the below workflow.

there are 4 levels of approvals

the approvals at any stage if approval rejected ... the requestor and the previous approvers need to get notification.

 

for this i created an event and add the activity and added Run script. 

 

my notification itself is not working.

Please help

1 ACCEPTED SOLUTION

@Are Kaveri,

 

you can push multiple approvers by using answer.push like below. Suppose say you want to send the notification to requester's manager and requester manager's manager, you can use below.

 

 

 

 

answer = [];
answer.push(current.variables.requestor.manager); 
answer.push(current.variables.requestor.manager.manager); 

 

 

 

 

In this case, the notification will be sent to requester's manager and requester manager's manager.

Also, you can directly dot walk in the TO of the notification like below.

SivaJyothiM_1-1693897149235.png

Highlighted are the two ways you can achieve this.

 

Mark this answer as correct and helpful if it solves your issue.

 

Regards,

Siva Jyothi M.

View solution in original post

7 REPLIES 7

Tony Chatfield1
Kilo Patron

Hi, unfortunately your post has no clear details of your configuration or code and this means the community cannot assess your issue. Perhaps you can update this thread with details of your scrip,  in plain text - I would think an after update BR on sysapproval_approver table would be the most appropriate way to trigger? and also details of your notification configuration, so that these can be reviewed\evaluated.

@Tony Chatfield1  

the below is the script i added in my work flow activity Runscript and added workflow activity Create event. still the previous approvers are not adding . where did i am doing wrong???

AreKaveri_1-1693883486365.png

 

 

 

 

 

 

var ans='';
var grApp=new GlideRecord('sysapproval_approver');
grApp.addEncodedQuery('sysapproval='+current.sys_id);
grApp.query();
while(grApp.next()){
	ans=grApp.approver+',';
}
gs.eventQueue('x_dev0777_e.reject',current,ans);

 

 

 

 

 i tried

 

Hi @Are Kaveri,

 

Directly you can use the notification activity in the workflow and in the advanced section of the notification write the below script and push the approver.

 

answer = [];
answer.push(current.variables.approver); //replace approver field with the correct field

 

And in the To of the notification, you can directly add the Requested for. You can fill the subject and message according to your requirement.

 

Mark this answer as correct and helpful if it solves your issue.

 

Regards,

Siva Jyothi M .

@Siva Jyothi M   my problem is i have 4 levels of approvals.

level-1 Requestor 

level-2 Requestor manager

level-3 Requestor manager manager

level-4 Requestor department head

 

so in level2 if the Requestor manager rejects the approval , then Requestor and Requestor manager should be notified

in level 3 if requestor manager manager rejects the approval , then Requestor, Requestor manager and Requestor manager manager should be notified.

 

thats why i went for Run script for copying previous approvers.

But my script was not working as expected throwing error