Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to check if user is part of specific group in Business rule condition

Chaiatnya
Tera Contributor

Hi,

I'm writing a business rule on User table, this business rule should execute only if the user is part of a specific group.

Can some one help how to put in Condition in advanced tab. I had a property created with the group Sys id

1 ACCEPTED SOLUTION

Or without toString:

gs.getUser().getUserByID(current.sys_id).isMemberOf(gs.getProperty('name of your property'))

 

View solution in original post

9 REPLIES 9

Pranav Bhagat
Kilo Sage

 

Use this to check whether the user is part of a group or not

gs.getUser().isMemberOf(current..PASSGROUPNAME)

gs.getUser will return the Logged in User, but I wanted to check the User whose record is updated is part of the group

 

Add this conditon and it will work.

gs.getUser().getUserByID(current.sys_id).isMemberOf(gs.getProperty("groupo_name"))

Check property name

SunilKumar_P
Giga Sage

Hi,

 

If this is not an scoped app, then try (gs.getUser().isMemberOf("Group Name");

If an scoped app then, have an script include which returns true / false and call the script include in BR condition.

var gr = new GlideRecord('sys_user_grmember');

gr.addQuery('group','group_sys_id');

gr.addQuery('user', gs.getUserID());

gr.query();

if(gr.hasNext() {

answer = true;

}