Set Incident Ticket On Hold by only selected group of users

Max Lin
Tera Contributor

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!!

7 REPLIES 7

Tony Chatfield1
Kilo Patron

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.

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! 

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

https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server_legacy/GUserAPI#GUser-hasRole_S...

and abortAaction if they do not have the role

https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server_legacy/c_GlideRecordAPI#r_Glide...

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...

Chetan Mahajan
Kilo Sage
Kilo Sage

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