Allow users with specific role to edit Impact and Urgency

Keerthana chama
Tera Contributor

Impact and Urgency fields in incident form is read - only. If user has a specific role, then he/she should be able to edit the impact and urgency so that priority gets altered. Please help me how I can achieve this.
Note: User should be able to change the two fields even after the form is submitted/saved

4 REPLIES 4

Runjay Patel
Giga Sage

Hi @Keerthana chama ,

 

Create filed level ACL for both filed and use below code.

// Allow access if the user has the specific role
if (gs.hasRole('itil_admin')) { // replace with your role
    answer = true;
} else {
    answer = false;
}

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Hi @Runjay Patel ,

Thank you for the reply!
 I tried this but didn't work. I investigated and found one OOTB UI policy which is making Urgency and Impact read-only. 
I have made changes to the script by adding the role in one of the conditions in the script and now I achieved my requirement this way.

Hi @Keerthana chama ,

 

UI Policy is not the right solution for this as user may try to change from list view. anyway if you are going with UI policy then use below code. Do not put any condition for ui policy just add below script.

function onCondition() {

    var role = g_user.hasRole('itil_admin');
    if (role) {
        g_form.setReadOnly('impact', false);
        g_form.setReadOnly('urgency', false);
    } else {
        g_form.setReadOnly('impact', true);
        g_form.setReadOnly('urgency', true);
    }

}

RunjayPatel_0-1733397059571.png

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

 

AndersBGS
Tera Patron
Tera Patron

Hi @Keerthana chama 

 

And what is your question? Above is not a question - just a statement ?

 

if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/