Check group membership in workflow activity

maneesh3
Tera Contributor

Hi,

I need kind help in a script for a workflow IF condition where it will check RITM End user is an member of an particular group then it will be YES and NO in other case. From there I will connect this to next activity for a approval process.

After ordering in catalog form, once RITM is raised then this IF condition should check RITM End user is a part of a group and then the answer is YES or else NO. 

Thanks a lot for the help!!!

 

1 ACCEPTED SOLUTION

Maniraj Jayaraj
Tera Expert

you can use script directly as you use in any other server side scripts:

 

in the Workflow IF activity try the below code:

 

var ourUser = gs.getUser().­getUserByID(current.requester);//current.requester - end user in RITM

answer = ifScript();

function ifScript()
{
if(­ourUser.­isMemberOf(group sysid/name))
{
return 'yes';
}
return 'no';
}

View solution in original post

5 REPLIES 5

rammohanraomadd
Kilo Guru

Hi,

 

Please use the below script:

 

answer = ifScript();

function ifScript()
{
var user = current.variables.requester;//Assuming requester is the variable that is storing the value of user who group membership to be checked
var grp_mem = new GlideRecord("sys_user_grmember");
grp_mem.addEncodedQuery("group.active=true^user=" + user);
grp_mem.query();
var count = grp_mem.getRowCount();
if(count > 0)
{
return 'yes';
}
return 'no';
}

 

Regards,

Ram M