How to restrict access to a field in the incident form?

Bill11
Kilo Expert

I need either a Business rule or UI policy that will allow me to cause a field to become read only unless you have a specific role.  I tried using a script from SN but so far I have not gotten it to work.  The script was in a business role. 

functiononLoad();{
var incidentState = g_form.getValue('incident_state');
if( incidentState =='6'|| incidentState =='7'){
g_form.setReadonly('priority',true);}}

1 ACCEPTED SOLUTION

And also for write access to a particular role. create a write acl like below:

 

find_real_file.png

View solution in original post

13 REPLIES 13

Bill11
Kilo Expert

Needed the space on the first line.  Thank you for that fix.  I still need to give access to edit based on role though.

Glad that helped you along 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Jason174
Tera Guru

Need a statement based around this... g_user.hasRole('role_goes_here')

Bill11
Kilo Expert

The script is also not setting the priority field to read only.  Do I need to run this in something besides a business rule?

This should go in an Client Script...honestly...that's how I would do it. Use this as a sample:

 

function onLoad()
{
     if(isLoading) return false;

       var rqdrole = g_user.hasRole('change_unlock');
       var state =   g_form.getValue('State');
     
}
if (state == 'Scheduled'   && rqdrole ){

       g_form.setMandatory('start_date',false); // This makes the field non mandatory
       g_form.setReadonly('start_date',false);

       g_form.setMandatory('end_date',false);    // This makes the field non mandatory   
       g_form.setReadonly('end_date',false);

}

else {
     
       if (state == 'Scheduled')
               g_form.setReadonly('start_date',true);
               g_form.setReadonly('end_date',true);
     
}

Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!