How to write business rule to restrict the visibility access to records for users depending on the groups and roles

Khyati Panchal1
Tera Contributor

Hello, 

I'm working on the VR items and I want to write the BR for the records to restrict the access of visibility for the records that are groups based on users and groups.

For eg: records only visible tot he users having access to specific group.

Any leads on this?

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use query business rule on that table.

But does your table have some group field etc

BR: Query - True

Condition: gs.getSession().isInteractive()

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	if(gs.getUser().isMemberOf("Group ABC"))
		current.addQuery('group', 'GROUP ABC');

})(current, previous);

Regards
Ankur

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

I have couple of groups, then?

Hi,

you need to write those many if else statements in above script

Regards
Ankur

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

If else conditions are not working. I have also trid with multiple seperate query BR on same table as if else was not working, still no luck.