Before Query Business Rule

taylor21
Mega Expert

Hi all,

I am creating a before query Business Rule that restricts record access based on if the current user has a matching role that the current assignment group also has. I have a strictly basic understanding of scripting so I have started by creating the following Business Rule which is currently working for showing the user only the records of the groups they belong to or if they are the customer of the record:

if (!gs.hasRole('admin') && gs.getSession().isInteractive()) {
	var queryString = 'caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^NQassignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744';
	current.addEncodedQuery(queryString);
}

 

I am looking for example scripts that I can manipulate to match my needs for this idea or anything that may point me in the right direction. 

 

Could I possibly create a dynamic filter option to utilize here? What would that look like? 

 

Thank you in advance!

1 ACCEPTED SOLUTION

taylor21
Mega Expert

Thank you all, I have opted to use a specific Assignment group type for this. For each department that needs to be separated, I have created a type that I have applied to the entire department's groups and I am matching the department specific role to the type in the business rule like so: 

Table: incident

When: before query

Script:

if (!gs.hasRole('admin') && gs.hasRole('its') && gs.getSession().isInteractive()) {
	var itsQuery = 'assignment_group.typeLIKE1e9345dedba8b3c0c33c7bec0f961928'; //Assignment group type is ITS
	current.addEncodedQuery(itsQuery);
}

View solution in original post

5 REPLIES 5

taylor21
Mega Expert

Thank you all, I have opted to use a specific Assignment group type for this. For each department that needs to be separated, I have created a type that I have applied to the entire department's groups and I am matching the department specific role to the type in the business rule like so: 

Table: incident

When: before query

Script:

if (!gs.hasRole('admin') && gs.hasRole('its') && gs.getSession().isInteractive()) {
	var itsQuery = 'assignment_group.typeLIKE1e9345dedba8b3c0c33c7bec0f961928'; //Assignment group type is ITS
	current.addEncodedQuery(itsQuery);
}