current.setAbortAction(true) doesn't work if nothing is changed to the incident record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2018 01:31 PM
I have a "before" Business Rule to prevent an update to an incident record if the 'Assigned to' user is not a member of the 'Assignment Group'. The BR only runs on 'Update', but only seems to work if you modify the record like change the value of a field. If you do not make any changes, the BR will not work.
I have set the Order field to 1 and to the low number like 10,000. Still doesn't work. I have added current.setWorkflow(false), and it still doesn't work.
The conditions are: assigned_to is not empty AND assignment_group is not empty
CODE:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var assigned_to = current.assigned_to;
var assignment_group_display = current.assignment_group.getDisplayValue().trim();
var assigned_to_display = current.assigned_to.getDisplayValue().trim();
var userObj = '';
userObj = gs.getUser().getUserByID(assigned_to);
if (!userObj.isMemberOf(assignment_group_display)) {
var msg = gs.getMessage('ERROR: ' + assigned_to_display + ' is not a member of ' + assignment_group_display + '. Please ensure the "assigned to" user is a member of the "assignment group".');
current.setAbortAction(true);
current.setWorkflow(false);
gs.addErrorMessage(msg);
}
})(current, previous);
Any thoughts why?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2018 02:37 PM
But as you stated the assignment group may not be filled in so your best option would be to make assignment group mandatory which will prevent someone assigning it to someone who is not a member of the group. As for you business rule you can try using the advanced conditions instead of the condition picker.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2018 01:36 PM
change below
var assigned_to_display = current.assigned_to.user_name.trim();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2018 01:47 PM
Thanks, but it didn't work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2018 02:01 PM
try
var userObject = gs.getUser().getUserByID(current.assigned_to.user_name).isMemberOf(current.assignment_group);
if (!userObject) {
var msg = gs.getMessage('ERROR: ' + assigned_to_display + ' is not a member of ' + assignment_group_display + '. Please ensure the "assigned to" user is a member of the "assignment group".');
current.setAbortAction(true);
current.setWorkflow(false);
gs.addErrorMessage(msg);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2018 02:04 PM
this worked for me
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var assigned_to = current.assigned_to;
var assignment_group_display = current.assignment_group.getDisplayValue();
var assigned_to_display = current.assigned_to.getDisplayValue();
var userObject = gs.getUser().getUserByID(current.assigned_to.user_name).isMemberOf(current.assignment_group);
if (!userObject) {
var msg = gs.getMessage('ERROR: ' + assigned_to_display + ' is not a member of ' + assignment_group_display + '. Please ensure the "assigned to" user is a member of the "assignment group".');
current.setAbortAction(true);
current.setWorkflow(false);
gs.addErrorMessage(msg);
}
})(current, previous);