ITSM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi Team,
I do not want any user to assign Incidents to a specific assignment group in ServiceNow and Only the members of the respective can assign the Incidents.
How can we achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi @piyushsewak ,
Goal :
Prevent non-members of a specific assignment group from assigning incidents to that group.
Only users who are members of the assignment group can assign incidents to it.
Use a Before Update Business Rule on the Incident table.
Script Example:
(function executeRule(current, previous /*null when async*/) {
// Only check if the assignment group changed
if (current.assignment_group.changes()) {
var newGroup = current.assignment_group;
if (!newGroup) return; // no group selected
var groupMembers = new GlideRecord('sys_user_grmember');
groupMembers.addQuery('group', newGroup);
groupMembers.addQuery('user', gs.getUserID());
groupMembers.query();
// If current user is NOT a member of the group
if (!groupMembers.next()) {
gs.addErrorMessage("You are not allowed to assign this incident to the selected group.");
current.assignment_group = previous.assignment_group; // revert to previous
current.setAbortAction(true); // stop update
}
}
})(current, previous);
Configuration
Table: incident
When: before
Insert: false
Update: true
Condition: current.assignment_group.changes()
Alternate approach:
You can also control this through Access Control:
Steps:
Create a new ACL on the incident.assignment_group field.
Type: record
Operation: write
Condition:
answer = gs.getUser().isMemberOf(current.assignment_group);
Also allow ITIL or admin users if required:
answer = gs.hasRole('admin') || gs.getUser().isMemberOf(current.assignment_group);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @piyushsewak ,
I tried your problem in my PDI and it is working fine, please check below script
Create before BR on incident table and add below code
(function executeRule(current, previous /*null when async*/) { // Add your code here if (current.assignment_group.changes()) { var group = current.assignment_group; var user = gs.getUserID(); // Check if user is a member of that group var grMember = new GlideRecord('sys_user_grmember'); grMember.addQuery('group', group); grMember.addQuery('user', user); grMember.query(); if (!grMember.next()) { gs.addErrorMessage('You cannot assign incidents to this group. You must be a member of the group.'); current.setAbortAction(true); } } })(current, previous);
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak