Making a field read only for user with role using UI policy

amacqueen
Mega Guru

I'm trying to make a field read only for a user with a specific role.

In the script associated with the UI Policy I have

function onCondition() {

gs.hasRole(x_9004_invoice_que.mgr);

}

We only have one user with this role however it is making the field read only for all users

Appreciate any assistance with this

1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron

Create a ACL to make the field readonly. It also restricts list view.


Regards
Harish

View solution in original post

5 REPLIES 5

Chandu Telu
Tera Guru
Tera Guru

HI Angus,



You can achive this fucntinality using 3 ways


1) ACL - Highly recommended


2) Client script


3) Ui policy



1) ACL:


Check the below link


restricting access to certain fields on a form



2) Client script


function onLoad() {


  var isXYZUser = g_user.hasRole('x_9004_invoice_que.mgr)');


  if (isXYZUser){


          g_form.setReadonly('request_date',true);


          //Similarly make all the required fields read only


  }


}



function onCellEdit() {


Implement the above kind of logic here to handle the list view locking


}


UI Plocliy



In 'Execute if true'-


var isAdmin = g_user.hasRole('x_9004_invoice_que.mgr');


if(isAdmin)


{


g_form.setReadOnly('fields1', true);


}


In 'Execute if false'-


g_form.setReadOnly('fields1', false);