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-21-2024 11:19 AM
@Annie10 try with the below script.
(function executeRule(current, previous /*null when async*/) {
if (!gs.hasRole("itil") && gs.getSession().isInteractive()) {
var u = gs.getUserID();
var userGroups = gs.getUser().getMyGroups(); // Get groups the user belongs to
// Query for records where the user is the requested_for, opened_by, in the watch_list, or in their assignment group
var qc = current.addQuery("requested_for", u)
.addOrCondition("opened_by", u)
.addOrCondition("watch_list", "CONTAINS", u);
// Add conditions for user's assignment groups
var groupCondition = qc.addOrCondition("assignment_group", userGroups[0]);
for (var i = 1; i < userGroups.length; i++) {
groupCondition.addOrCondition("assignment_group", userGroups[i]);
}
gs.info("Query restricted to user: " + u);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 11:10 AM
Hi @VarunS
I'm trying to understand the following error after executed the BS. What is it means and how to fix it?
==== Error and stack:
org.mozilla.javascript.EvaluatorException: Java class "com.glide.collections.StringList" has no public instance field or method named "0". (sys_script.1c446a8e835a4a1008469796feaad356.script; line 13)