Warning message associated with groups
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
I need to insert a warning and blocking message associated with specific groups. How can I do this?
Currently I'm using Business Rules, but I haven't implemented them correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
When do you want to show the warning or block message?
It depends on your use case. You can use Business Rule or Client Script to show the message.
Also if you can post the current BR script you have?
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
The message needs to be displayed when a specific group is selected; the script I created is associated with both input and output groups.
I'll send the standard script:
(function executeRule(current, previous /*null when async*/) { var allowedGroups = ['Group A', 'Group B', 'Group C']; var destinationGroups = ['Group D', 'Group E', 'Group F']; if (destinationGroups.indexOf(current.assignment_group.name) > -1 && allowedGroups.indexOf(previous.assignment_group.name) === -1) { gs.addErrorMessage('You do not have permission to assign to this group.'); current.assignment_group = previous.assignment_group; // Reverts the change } })(current, previous);
I didn't do it through the Client Script because it's associated with a catalog item, and I need it to be associated with a group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
I dont see any issue. I would just change this to
allowedGroups.indexOf(previous.assignment_group.name) == -1
== instead of ===
Also this should be an onBefore BR Update incase you have it set as onAfter
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
48m ago
Hi @Polyanna Silva ,
Correct Business Rule Setup
Here’s how you can adjust your script:
- Trigger Conditions
- Table: task (or incident, change, etc. depending on where assignment groups are used).
- When: before update (so you can block the change before it’s saved).
- Condition: assignment_group changes.
Script Example
(function executeRule(current, previous /*null when async*/) {
var allowedGroups = ['Group A', 'Group B', 'Group C'];
var destinationGroups = ['Group D', 'Group E', 'Group F'];
var prevGroup = previous.assignment_group.getDisplayValue();
var newGroup = current.assignment_group.getDisplayValue();
// Check if new group is restricted AND previous group is not allowed
if (destinationGroups.indexOf(newGroup) > -1 && allowedGroups.indexOf(prevGroup) === -1) {
gs.addErrorMessage('You do not have permission to assign to this group.');
current.setAbortAction(true); // stops the update
}
})(current, previous);
Key Fixes
- Use getDisplayValue() instead of .name — safer because assignment_group is a reference field.
- Use current.setAbortAction(true) instead of reverting the value. This blocks the save entirely, which is cleaner.
- Keep the rule as Before Update so the error message shows and the transaction is stopped.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Best,
Anupam.
