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

Willem
Giga Sage
Giga Sage

Hi Kri,

 

To check the group from your property use:

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

Replace above 'name of your property' with the name of your property between quotes.

 

Returns true if the user is a member of the group you specified in your property. Returns false if not a member of that group. So with above it will execute (true) for users part of that group.

Chaiatnya
Tera Contributor

Hi Willem,

gs.getUser returns the sys id of logged in user, but I need to check the user whose record is updated is part of the Group

 

Use:

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

Or without toString:

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

 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Is it logged in user or the user who is getting updated

1) If logged in user then this single line should work in BR condition

gs.getUser().isMemberOf("YOUR GROUP NAME HERE")

2) If for the user who is getting updated then below line should work in BR condition

gs.getUser().getUserByID(current.sys_id).isMemberOf("YOUR GROUP NAME HERE")

Regards
Ankur

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