Group Approval Workflow Advance Script

_Samay
Tera Expert

Dear Team,

Hope, you all are doing well.

I’m looking for some help in workflow where in Group Approval Activity at least 6 approvals are required to approve a change. But, not sure how we can achieve this from scripting.

If anyone can help with samples like how does script looks like, then it’s really help me.

Appreciate your help and support.

1 ACCEPTED SOLUTION

Najmuddin Mohd
Mega Sage

Hello @_Samay 

Can you try the below code.

 

answer = '';

for(var id in groups){
	var group = groups[id];
	if(group.rejected >= 1){
		answer = "rejected";
	}
	else{
		var numberOfApprovals = 6;
		var approvedArray = group.approvalIDs["approved"]; // sysId of the users who approved

		gs.log("Approved array: " + approvedArray);

		if(approvedArray.length >= numberOfApprovals){
			answer = "appproved";
		}
	}
}

 

 

If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@_Samay 

this should work

Percentage or Majority-based Workflow Approvals 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@_Samay 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@_Samay 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Najmuddin Mohd
Mega Sage

Hello @_Samay 

Can you try the below code.

 

answer = '';

for(var id in groups){
	var group = groups[id];
	if(group.rejected >= 1){
		answer = "rejected";
	}
	else{
		var numberOfApprovals = 6;
		var approvedArray = group.approvalIDs["approved"]; // sysId of the users who approved

		gs.log("Approved array: " + approvedArray);

		if(approvedArray.length >= numberOfApprovals){
			answer = "appproved";
		}
	}
}

 

 

If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.