Set all fields to read only when active = false without affecting related list edit button

Emma Angarita
Tera Expert

Hi all, I have a custom app that I am trying to set all fields on the form as ready only when the ticket is closed - ie. active = false. This is successful using a write ACL with the condition of active = true: 

 

EmmaAngarita_2-1668559498344.png

 

But, when this condition is set on the ACL, the edit button on the related list tab of the same table disappears for the 'user' role, and is only visible for admins. I have checked and confirmed that the omit edit button is not checked for this list control, and there is no impact to the new button if the ACL condition is or is not there. When the ACL condition of active = true is removed, the edit button is visible again, but of course all fields are editable even when the ticket is inactive.  

 

 

EmmaAngarita_1-1668559412138.png

 

EmmaAngarita_3-1668559523091.png

 

How do I achieve both, as one cancels out the other? 

- set all form fields to read only when ticket is inactive 

- enable edit button on related list 

 

Many thanks 

7 REPLIES 7

Saurav11
Kilo Patron
Kilo Patron

Hello

 

The reason why edit button disappears isnbeacuse you have written a write Acl.Had you written a create ACL the new button woukd have disappeared.

 

Now for making the fields readonly create on onload client script with the below code:-

 

if(g_form.getValue('active')=='false')
{
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
}

Please mark my answer as correct based on Impact.

Thanks for the response, unfortunately this didn't work - fields are still editable. I modified the script slightly ( == false instead of == 'false' - this worked, but then I received the following errors: 

 

function onLoad() {
if (g_form.getValue('active') == false) {
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
}
}

EmmaAngarita_0-1668579410330.png

 

Is this a scoped table? Are all the fields in the same scoped application as the scoped table? Did you write the script in the same applicatuon. Isther any other field which is from different apllocation than the table or the script?

Is this a scoped table?

- yes, it extends task table 

 

Are all the fields in the same scoped application as the scoped table?

- no, it extends the task table, so many fields are part of task table

 

Did you write the script in the same application.

- yes, it is written in the same scope as the form it refers to - ie. the scoped app, not global for task

 

Is there any other field which is from different application than the table or the script?

- yes, from task table