Before 'Query' Business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 08:53 AM
Hello,
I have created a below 'Before-Query' business rule on Task table to restrict visible access to users with custom role where users with custom role will see only records that are assigned to one of their groups.
But, I want to have an encoded query for incident table like if "assignment group is one of my groups" and if "caller_id is me". How can I compensate the new encoded query in the same business that should work for incident table only since caller_id field is only on incident table.
Any help is appreciated.
Thanks,
Rocky.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 09:30 AM
Hello,
Thanks for the response. So, I will try to make it simple. in the screenshot I provided I have the encoded query that works on entire task table, So now I wanted to have a separate new encoded query that should work only for Incident table. So, should I create new BR for incident table or is there a way I compensate in the same BR?
Thanks,
Rocky.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 10:22 AM
Hello,
Yes, we have sys_class_name but, caller_id field is not on Task table right, it is on Incident table and my encoded query will include caller_id field.
Thanks,
Rocky.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 12:56 PM - edited 12-16-2022 01:05 PM
Hey,
I tried the below code but it is not working. with the below script when I open incident.list the script 'else' condition is being executed.
But, when I open Incident.list the script in 'if' condition should be executed, And if I open any other table that extends Task table the script in 'else' condition should be executed.
(function executeRule(current, previous /*null when async*/ ) {
if (current.sys_class_name == 'incident') {
current.addEncodedQuery("ref_incident.caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORassignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744");
} else {
current.addEncodedQuery("assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744");
}
})(current, previous);
Thanks,
Rocky.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 08:43 PM
@Ben42 You can use below code to add the query for incident in same business rule.
ServiceNow Community Rising Star, Class of 2023