Before Query Business Rule Incident

Cobee
Tera Expert

Hello, 

I am looking to create a before business rule query that involves only snc_internal users. We have different departments that require access to incidents when a user from either department A or department B submits an incident with a specific category on our service portal. We attempted the a read ACL route and is populating the correct data, but is very clunky for the end users. They have to sift through pages of incidents where it tells the user that "10 records have been restricted" etc. I think a before business rule query with the same condition would be a better approach. The issue is that we would have to build this condition based on department. My thought was to clone the OOB "Incident Query" and alter the condition based on our requirements. 

 

Any guidance on how to script this by department would help tremendously. Any other tips or insight on other methods to achieve this goal would also be welcomed. 


Thanks 

4 REPLIES 4

Maik Skoddow
Tera Patron
Tera Patron

Hi

as you did not provide enough details, I cannot answer your question.

But you can watch the following video to get an idea on how to implement a respective Before Query Business Rule.

https://www.youtube.com/watch?v=Xtj9nvnryr8&list=PLkGSnjw5y2U5jTsF7i2yRZPdk3lm88SN8&index=26

Kind regards
Maik

 

Appli
Mega Sage
Mega Sage

Hi, consider to use the script below (to be added to the advanced tab of Before Query BR).

It forces users from HR and IT departments to only see incidents, raised for Software category and by callers from either Finance or Product management departments.

(function executeRule(current, previous /*null when async*/) {
   // Add your code here
   if (userIsInDepartments()) {
	   current.addEncodedQuery('caller_id.department=a581ab703710200044e0bfc8bcbe5de8^ORcaller_id.department=9a7ed3f03710200044e0bfc8bcbe5db7^category=software');
   }

function userIsInDepartments() {
 var gr= new GlideRecord('sys_user');
 gr.get(gs.getUserID());
 if (gr.department.name.toString()=='HR' || gr.department.name.toString()=='IT')
   return true; 
}
})(current, previous);

Hope it helps

Hope it helps

Thanks for the quick and detailed response. I have tried this method and was not successful on our instance. I think we are still having conflicts with OOB incident Business Rules. The users in question here do not have roles associated with their accounts, only snc_internal. So I think we are limited to what can be accomplished when viewing other department records. We will keep troubleshooting. 

 

Thanks again

Hi, agree - but if it is about viewing records, consider to apply ITSM specific role  sn_incident_read to these users; it should grant them an access to incidents however BR will still restrict an access as per script above.

Hope it helps

Hope it helps