make field read only

ammar_k
Tera Expert

 

Hello,

I've created a catalog item and need to set a field to read-only. I attempted to use an onLoad client script with:

 
g_form.setReadOnly('variable_name', true);
 

However, this approach didn’t work.

The variable in question is a single-line text field and is not linked to a table field.

Do you know how I can achieve this?

4 REPLIES 4

Vasantharajan N
Tera Sage

@ammar_k - Please use the "Catalog UI Policy" to make a field Readonly, Mandatory or Visible, instead of client script

PrashantLearnIT
Tera Sage

Hi @ammar_k 

 

Please use the Catalog UI Policy to make the variable readonly.

 

PLease mark my answer correct if it helps

Ankur Bawiskar
Tera Patron

@ammar_k 

Are you sure that variable is not mandatory?

If it is mandatory then you cannot make it readonly

first make it non mandatory and then readonly

g_form.setMandatory('variable_name', false);
g_form.setReadOnly('variable_name', true);

If my response helped please mark it correct and close the thread so that it benefits future readers.

AndersBGS
Tera Patron

Hi @ammar_k ,

 

Why not utilizing a catalog UI Policy to make it read only?