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:11 PM
Thanks, but this did not work either. Remember, I'm trying to test the rule on an existing incident record where the assigned_to user is not a member of the assignment group. In my test, I'm not changing or modifying any fields. I'm simply clicking 'Save'. It proceeds without giving me an error message. However, if I change any value of any field, then it will give me an error.
Is this expected behavior?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2018 02:16 PM
If you are not making any change than business rule will not run since there is no change.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2018 02:28 PM
Thanks. I'm okay if this is expected behavior. If it is, is there any way to get it to work without changing any value of the incident record?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2018 01:39 PM
Hey natecousins,
Try this and it will work for you.
Remove the codition assigned_to is not empty.
Best Regards,
Rahul
Please mark this as COrrect / Helpful if it resolved your query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2018 01:47 PM
Thanks, but this did not work.