Set Incident Ticket On Hold by only selected group of users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 08:33 PM
Hi, i have a requirement to allow only specific group of users to set an Incident Ticket Status On Hold.
This users can either be manually selected, or i also can create a group to hold them.
Is this possible?
Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 08:47 PM
Hi, as a simple solution I would use a group and apply a custom role to the group, so any user added to the group inherited the role\ability to set On Hold.
You would need an on-load client script to hide the 'On Hold' choice option in UI for users that didn't have the role,
and might want to also consider a before update BR to abort the update if a user without the role somehow managed to apply an On Hold state - possible if the UI loads incorrectly in browser.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 08:50 PM
Workable! Would it be possible for you to give me a sample script to start with? I would really appreciate that alot if possible. Thank you so so much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 09:06 PM
For the onload client script something like this
//if the user does not have the role, then hide the option from them
if(!gs_user.hasRoleExactly('customRoleName')) {
g_form.removeOption('state' 3);
}
Once you have confirmed this works, I would suggest that you disable temporarily and make an attempt at configuring the BR yourself as it would be a good learning experience and happy to help\answer questions if you have an issue.
You will want to use hasRole to check if the user has the required role
and abortAaction if they do not have the role
Possibly also including a warning message to the user.
https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server_legacy/c_GlideSystemAPI#r_GS-ad...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 09:07 PM
Hello @Max Lin ,
You can achieve this by creating new group for ex. "Incident On Hold Users". Add users in this group who should have the ability to set Incident On Hold. Then write Before BR on Incident. Condition would be status changes to on hold. write script as below.
// Check if the Incident Status is being set to On Hold
if (current.incident_state == 4) { // Make sure value of On Hold
// Check if the current user is a member of the 'Incident On Hold Users' group
if (!gs.isMemberOf('Incident On Hold Users')) {
// If the current user is not a member of the group, prevent the status change
gs.addErrorMessage('You do not have permission to set the Incident status to On Hold.');
current.setAbortAction(true);
}
}
Kindly mark correct and helpful if Applicable