Make section fields read only using onload client script

bandideena12
Tera Contributor

Hi,

In my table there are 2 sections, I need one field under the section, which should be read only when the state is assigned (after making the changes as state=assigned and saving/submitting the form). i tried the below code it is working for the fields not in section but not working to section fields. The script is...

 

var stat = g_form.getValue('state');
   
   if (stat == '3') {
           
            g_form.setReadOnly('triage_outcome_summary', true);
           
        }
Example: if I make the description field readonly using the above script its working, but if I select the field under the other section the script is not working. Please help me on this script.
8 REPLIES 8

sushantmalsure
Mega Sage
Mega Sage

Please check if field is set as mandatory.

Looking in your screenshot field 'Triage Outcome Summary' is mandatory and making it read only will be restricted and that may be the reason for not making field read only. This is completely logical when field is mandatory then it can not be read only.

Next poosibilties:

1. Identify from where this field is made mandatory (client script / UI policy) and then adjust the code based on your condition to make it readonly.

or

2. in you above code, make field non-mandatory first and then make it read only.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

bandideena12
Tera Contributor

Thank you all, your responses helped me but not to achieve the proper requirement

What did you create can you show that. 

-Anurag

Anurag Tripathi
Mega Patron
Mega Patron

You can Use the same via UI policy & UI Policy Actions, No code solution and more efficient,

-Anurag