- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 03:57 AM
Hi all,
I have a requirement where I have to show a List view of incidents which are assigned to my group only.
I know this can be achieved by Before Query BR but I have never written a query BR. Can anyone help me with it.
Thanks!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 04:26 AM
Hello,
So your requirement is any user going to list view should see only his own assignment group incidents then write the below code in a before query BR:-
Code:-
(function executeRule(current, previous /*null when async*/) {
current.addEncodedQuery("assignment_groupIN"+ gs.getUser().getMyGroups().toArray().join());
})(current, previous);
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 04:07 AM
Hi Siddharam,
Well, yes it can be achieved by a query business rule, but a query business rule goes for all queries to the table - so it is not just for a list. It means no one will be able to see incidents assigned to other groups than their own - no matter where they look. I would rather think you can get your view by just adding a filter to a module by having "assignment group is (dynamic) one of my groups".
If you requirement is for ALL queries to incident and NOT just for a list view, then here is a great guide for query business rule: https://www.servicenow.com/community/developer-blog/query-business-rules-a-definitive-guide/ba-p/227...
Also please remember to include that the caller, opened_by or others can see an incident, so you just don't only create a rule about the assignment group, but think about all stakeholders that should be able to view the incident(s).
Best regards,
Sebastian Laursen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 04:26 AM
Hello,
So your requirement is any user going to list view should see only his own assignment group incidents then write the below code in a before query BR:-
Code:-
(function executeRule(current, previous /*null when async*/) {
current.addEncodedQuery("assignment_groupIN"+ gs.getUser().getMyGroups().toArray().join());
})(current, previous);
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 09:47 AM
Hello,
If my answer helped you can you also mark it as correct.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 05:03 AM - edited 10-19-2022 05:18 AM
I think you shouldn't be using query BR for this requirement, if you use query BR then each and every user will be able to see only incidents which are assigned to their group which is not good process wise. There are many other users who needs to see incidents even if they are not part of group.
Instead you can plan to provide them new module with below filter ( you can make filter non-editable if required)
Regards,
Abhijit
ServiceNow MVP