How to filter on Approval Group in sysapproval_approver table?

Paul125
Kilo Guru

Hello, I have tried below queries but nothing seems to work. Please someone suggest me the right one. Thanks

var approvals = new GlideRecord("sysapproval_approver");
	approvals.addQuery('sysapproval', current.sys_id);
	approvals.addQuery('assignment_group', 'de7c36dedb90a3c838a5cae3b99619b4');
//also tried
       approvals.addQuery('sysapproval_group', 'de7c36dedb90a3c838a5cae3b99619b4');
1 ACCEPTED SOLUTION

It looks like only individuals are put into the sysapproval_approver table and it does not seem to reference what group the are a member of directly.  It looks like you would need to search sysapproval_group and get the sys_id from there of what you are looking for approvals on so you can then search for the members of that group who have rejected the request in the sysapproval_approver table.  Note it only looks like the table sysapproval_group table gets populated if the workflow activity of Approval - Group is used to set the approvers.  The group in the sysapproval_approver table seems to be a reference to which group was set as the approver in the sysapproval_group table.  Hopefully this was not to confusing as I confused myself was I was looking at the two table and testing what populated each from the workflow.

View solution in original post

13 REPLIES 13

Brian Lancaster
Tera Sage

Can you please provide your entire script and an explanation on what you are trying to accomplish?

This is part of workflow. I am using this script in IF activity to check if there is any rejections exist from particular group. Thanks.

answer = ifScript();

function ifScript() {
	var approvals = new GlideRecord("sysapproval_approver");
	approvals.addQuery('sysapproval', current.sys_id);
	approvals.addQuery('assignment_group', 'de7c36dedb90a3c838a5cae3b99619b4');
	approvals.addQuery('state', 'Rejected');
	approvals.query();
	if(approvals.next()){
		return 'yes';
	}else{
		return 'no';
	}
	
	
	
	
	
}

I think you need to change sysapproval in your query to sys_id (as I don't think there's a field called that on that table OOB anyway)

And remove assignment group query as well, then just do you state query with 'rejected or 'Rejected, ensure you are doing the right value there.

That should work.

All I mentioned above will check that specific record for any rejected entries. The group isn't on that table either I believe.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thanks for the reply Allen. I should be doing the group query as I just need to track group approvals not individual user approvals. Thanks!