Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

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

Query is not required.

this will work; did you try that

answer = ifScript();

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

Regards
Ankur

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

Yes this works as well. Thanks Ankur.