Group Approval?

na93
Mega Expert

Hi,

We have a group approval for Change Requests, this approval goes to the assignment group members for approval.


However what I would like to do is only for the approval to go to those members within the assignment group who have the role called "Change Approver" which I have created, I know I could create separate groups but I wish to avoid doing so.


Has anyone ever used such a script to do this and is it possible?

Any help appreciated.

Cheers.
Nabeel

1 ACCEPTED SOLUTION

Hi Nabeel,



This is what i have tested and it works fine for me, are you having the required group assigned before workflow starts. I have just tested with this setup and it's working. I would have one 'Wait for Condition' to make sure assignment group is there before sending to approval, like below.



find_real_file.png


find_real_file.png



Please make sure you pass the correct sys_id of your role.


find_real_file.png



Result:


find_real_file.png


View solution in original post

19 REPLIES 19

Please try this if it works.



var answer = [];


var groupMemberships = new GlideRecord('sys_user_grmember');


groupMemberships.addQuery('group', current.getValue('assignment_group'));


groupMemberships.query();


while(groupMemberships.next()){


        if (groupMemberships.getValue('user').hasRole('change_approver')){


                  answer.push(user.sys_id);


                  }


}


Unfortunately the approval still goes to all members of the assignment group rather than the user who has the change_creator role.



Capture2.JPG



Thank you for your time so far for helping me


nishailame
ServiceNow Employee
ServiceNow Employee

You don't have to select group in Groups field. That part will be taken care by advance script. Remove $(assignment_group) from Groups field and Try.




 


Thanks.


PS: Hit like, Helpful, Correct and Endorse, if it answers your question.


Let us know if it worked.


Thanks both! Getting a bit further not but it's throwing up the below error for the script in the workflow?



There is definitely members of the assignment group with the role of "change_approver"3.JPG