Restrict Changing of Priority

briansoucie
Kilo Contributor

Hello All,

I am not very well versed in scripting at all and I need some help from the community.

I am trying to restrict the lowering of a priority on incident tickets by technicians (which increases the SLA).

I have created a role that I will assign to the Team Managers and I want to allow them to change the priority.

I have looked through various postings and thought the screenshot of the client script below would work but I was wrong.

priority script.PNG

Error:

Priority error.PNG

We do NOT use impact and Urgency. We have 9 different Priorities (1-9)

So anyone (except a manager with the Team Manager role) would be unable to lower a priority and extend the SLA.

Increasing the priority would not be restricted.

Can anyone assist or is there a better way to do this?

Thanks in advance for your help.

7 REPLIES 7

Stephen Whitney
Kilo Expert

Brian,



You could change the client script to just validate that the current user has the required role (Team manager) to modify the field otherwise, without that role the field is read-only. Ex:



function onLoad() {


    //Type appropriate comment here, and begin script below


      if(g_user.hasRole('JR - TeamManager')){


              g_form.setReadOnly('priority',false);


              }


              g_form.setReadOnly('priority',true);


}


Stephen,



Thanks for the response…but would that prevent them from assigning a priority or increasing the priority as well? I need them to be able to set a priority initially and also be able to increase the priority if needed.



I am very green when it comes to this scripting…..




Thanks


Brian


Okay, let's try this....



Update line 7:



      var isTeamManager = g_user.hasRole('JR - TeamManager');



Currently, the script is encountering an error because it does not understand g.hasRole.


Actually, I think this should work. Comment out line 7 and update line 8 to be:



if(!g_form.isNewRecord() && oldValue < newValue && !g_user.hasRole('JR - TeamManager')){



That should do the trick.