If state is 'closed' then make all the fields read-only for all the users except 'admin'.how to achieve the same
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 05:02 AM
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 05:32 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 05:18 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 01:26 AM
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