If state is 'closed' then make all the fields read-only for all the users except 'admin'.how to achieve the same

Veera raju
Tera Expert

Hi,

Can any one help me on the below query:

If state is 'closed' then make all the fields read-only for all the users except 'admin'.how to achieve the same.

Thanks in advance,

7 REPLIES 7

Answer to your question is Yes but normally all the fields do not become Read Only even If you write a ACL on Problem Table because there are some fields like State, Short Description etc which are inherited from the Task Table so in order to Make all the fields Read Only you need to write separate ACL for each of the fields which are not becoming Read only i.e the ones which are inherited from Task Table as there are specific ACL already written for those fields on the task table .

So either you can write individual ACL for those fields or use a Client Script as mentioned above to make all the fields Read only at Once or even you can write a Data Policy using the same script in the Run Script section with condition as State is Closed on the Problem Table.

 To know more about ACL heck this LINK

 

 

asifnoor
Kilo Patron

You need to write a client script like below and check.

function onLoad() {
   //Type appropriate comment here, and begin script below
	if(!g_user.hasRole("admin") && g_form.getValue("state")==7) {
	 var fields = g_form.getEditableFields();
         for (var x = 0; x < fields.length; x++) {
           g_form.setReadOnly(fields[x], true);
         }
	}
}

Mark the comment as a correct answer and also helpful once worked.

Viraj Hudlikar
Giga Sage

Hi Veera,

Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.

Regards
Viraj