How to hide SLA field for non-admin users when stage changes to cancelled?

KarolisM
Tera Contributor
I would like to hide the SLA field for non-admin users when the stage changes to canceled,

So that only admin users can view SLA details at the stage when an incident is cancelled.
What would be the best solution to achieve this? Any ideas?
KarolisM_0-1717569577614.pngKarolisM_1-1717569593454.png

 

7 REPLIES 7

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @KarolisM 

 

But why to hide from NON admin? ITIL users are actually users who should know these status of SLA. 

 

You can do via Client script but I will not recommend.

*************************************************************************************************************
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]

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

swathisarang98
Giga Sage
Giga Sage

Hi @KarolisM ,

 

You want to hide the entire Task Sla section for non admin user when incident state is cancelled ?

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

That is correct @swathisarang98 

With the possibility to unhide it if the user would like to see it again. 
What kind of script I would need to use to achieve it. I have tried several options which haven't been successful. Including Client Script.

KarolisM_1-1717592572002.png

 



KarolisM_0-1717592134431.png

 

@KarolisM ,

 

i created a onload script you can write fro onchange aswell with same code , but if user dont have admin role it will hide the entire Related list ,

swathisarang98_0-1717704576772.png

 

function onLoad() {
   if (g_form.getValue('state') == '8')//chceking state is cancelled 
   {
        var userRole = g_user.hasRole('admin');//checking role is admin or not
		alert(userRole);
        if (userRole == 'false' || userRole == false) { 
            g_form.hideRelatedLists('task_sla.task');//hide related list
        }

    }
 }

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang