Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to restrict visibility of the 'closed' option in the 'state' field

Sahar_Kaizer
Tera Contributor

Hi,

I've established a 'u_support_feedback' table containing a 'state' field, where one of the values is 'closed.'

I want to restrict visibility of the 'closed' option in the 'state' field to users without the 'mac_departmentTL' role.

This means only users with the 'mac_departmentTL' role should be able to close records.

 

How can I implement this?

 

Thanks,

Sahar

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Sahar_Kaizer 

 

You can add the role condition in Closed UI Action like

 

https://www.servicenow.com/community/developer-forum/restrict-the-visibility-of-the-incident-records...

https://www.servicenow.com/community/developer-blog/managing-access-to-ui-actions-with-conditions-ro...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Prathamesh G
Kilo Sage

Hello @Sahar_Kaizer,

 

If you don't have any UI action to close that ticket, you can create a new UI action with restricting the UI action only for the specified user with role. 

 

Additionally, if any other user tries to change the state to close, you can create onChange client script when the state changes to 'Close'. And you can check if the user don't have the required role to close the ticket, you can add a alert/error message indicating that user cannot change the state to 'Close' by setting the state to its previous value.

 

If my above solution resolve your issue, Please marked the solution as 'Accepted Solution' and also marked it as 'Helpful'.

 

Thank You.

Prathamesh.

Murali27
Tera Contributor

Hi @Sahar_Kaizer ,

 

Write an Onload Client Script as follows to hide the State value "closed" provided if the logged in user don't  have mac_departmentTL' role.

 

function onLoad() {
   
if (!(g_user.hasRole('mac_departmentTL'))){
g_form.removeOption('state', 7); // In your case please consider the value of closed choice.
}
}

 

Regards,

Murali.

Please mark my answer as helpful and the solution accepted if it serves the purpose.