Please help with Business Rule Script conditions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 06:24 PM
Hello,
Could someone please help review the code? It is not working. The purpose of the business rule is to allow users to see records that are assigned to their team, but not records assigned to other teams. Thank you.
When to Run: Before, Query
(function executeRule(current, previous /*null when async*/) {
if (!gs.hasRole("itil") && gs.getSession().isInteractive()) {
var u = gs.getUserID();
var qc = current.addQuery("requested_for", u).addOrCondition("opened_by", u).addOrCondition("watch_list", "CONTAINS", u).addOrCondition('assignment_group', '927934e41b6bf0104425cb35624bcbe9');
gs.info("query restricted to user: " + u);
current.addQuery('assignment_group', '927934e41b6bf0104425cb35624bcbe9');
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 09:48 PM
Hi,
Consider i am member of a group called "Service".
There are 10 RITM's in total.
Out of 10
- 3 are assigned to "service" group
- 1 is opened by me
- 1 is requested for me
If I logged in to the system I should be able to see only 5 RITM's out of 10.
Is this your requirement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 09:54 PM
@Community Alums
Thank you for helping. That is perfectly correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 09:56 PM
@Annie10 In this case there is no need for any BR. You can follow the steps I mentioned in earlier reply.
I started answering community questions recently. If my answer helped you in any way, please mark it as helpful or correct. It would be a great boost.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 10:04 PM
@Community Alums ,
I have never modify the ACL before, Where do I enter this code the you provided:
sys_id=d9694407c3923000c111113e5bba8ffd&sysparm_view=&sysparm_domain=null&sysparm_domain_scope=null&sysparm_record_row=5&sysparm_record_rows=14&sysparm_record_list=name%3dsc_req_item%5eORnameSTARTSWITHsc_req_item.%5eoperation%3dread%5eORDERBYDESCsys_updated_on
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 10:14 PM
Redundant Queries: It appears that the line current.addQuery('assignment_group', '927934e41b6bf0104425cb35624bcbe9'); is redundant as the same query condition is already being added in var qc.
Proper Query Construction: Ensure that the queries are built correctly and logically.
(function executeRule(current, previous /*null when async*/) {
if (!gs.hasRole("itil") && gs.getSession().isInteractive()) {
var u = gs.getUserID();
var qc = current.addQuery("requested_for", u).addOrCondition("opened_by", u).addOrCondition("watch_list", "CONTAINS", u).addOrCondition('assignment_group', '927934e41b6bf0104425cb35624bcbe9');
gs.info("query restricted to user: " + u);
}
})(current, previous);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks