isMemberOf not working in Workflow

Vishwa Pandya19
Mega Sage

Hello,

I want to check if the RITM opened by field user is a part of "HR Intergration Group" or not. 

I am using this if script in workflow, but it is showing error .

answer = ifScript();

function ifScript() {
var name = current.opened_by;
var grp = "05bc6e8fdb14401025c85a35dc9619b0";  //HR integration group sys_id
if (name.isMemberOf(grp)) {
return 'yes'; 
}
return 'no'; 
}

The error is as follows:

Cannot find function isMemberOf in object.

Please help.

1 ACCEPTED SOLUTION

Use this sample script to design your script , it will work

 

var user = 'admin';
var group = "Hardware";
if (gs.getUser().getUserByID(user).isMemberOf(group)){
gs.log( gr.user_name + " is a member of " + group);
}

View solution in original post

11 REPLIES 11

suvro
Mega Sage

You can try 

getUserByID(name).isMemberOf(group)

Not working. 

Cannot find function getUserByID in object.

Maik Skoddow
Tera Patron
Tera Patron

Hi @Vishwa Pandya 

there is no API method isMemberOf() on the sys_user table.

Maybe you are confusing this with gs.getUser().isMemberOf(). But this method only works for the logged-in user.

In your case, you have to perform a lookup in the respective table by yourself to find out whether a user is member of a group or not.

Kind regards
Maik

Oh okay got it. 

Will creating a script include help then?