Need to check of the requested for user is part of a group selected on catalog form

Kishan4
Mega Expert

Hi all,

 

I have a requirement, where on a catalog end user submission form we have two fields 'caller' and 'group' fields which has to be filled by the user.

 

Now the requirement is in the work flow we need to check if the user in the caller is part of the group value in the variables. If the user is part of that group we need to trigger approvals in the workflow, other wise skip the approval.

 

Please suggest. Thanks in advance.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Kishan

Use if activity and below script; the yes output would go to approval activity; the no output would go to the activity which is next to approval in workflow

Ensure you use proper user and group variable in below script

answer = ifScript();

function ifScript(){

var userObject = gs.getUser().getUserByID(current.variables.userVariable);

if(userObject.isMemberOf(current.variables.groupVariable))
return 'yes';

}

else

return 'no';

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

10 REPLIES 10

Hi Kishan,

Any update on this?
Can you mark the answer as Correct, Helpful if you were able to achieve the requirement & then close the thread.

Thanks in advance.

Regards,

Sanket