Catalog client script is not making variable read only on catalog form.

Obito
Tera Expert

Catalog client script is not making variable read only on catalog form. The variable name is 'Tier Confirmation' 

Here I am checking if catalog task state is closed complete and task name is 'xyz Tier Confirmation'

 

function onLoad() {
    //Type appropriate comment here, and begin script below
    if (g_form.getValue('state').toString() == '3' && g_form.getValue('u_task_name') == 'xyz Tier Confirmation') {
        g_form.setReadOnly('tier_confirmation', true);
    }
}

 

 

6 REPLIES 6

Deepak Negi
Mega Sage
Mega Sage

Hi

 

try

 

g_form.setReadOnly('variables.tier_confirmation', true);

Kieran Anson
Kilo Patron

Have you debugged your code to see what value "u_task_name" is returning? You may want to try case-insenstive match by using .toLowerCase()

Brad Bowman
Kilo Patron
Kilo Patron

Add alerts to the script before the if statement to see if both conditions are met.  Also make sure the 'tier_confirmation' variable name is exactly correct (case and space-sensitive) and is not mandatory, or the read only statement will be ignored. 

Anand Kumar P
Giga Patron
Giga Patron

Hi @Obito ,

 

Try below script 

 

function onLoad() {

        var taskState = g_form.getValue('state');

        var taskName = g_form.getValue('u_task_name');

alert(taskName);// paste the alert tasName in below if condition as this is case and space sensitive 

 

        if (taskState == '3' && taskName === 'xyz Tier Confirmation') {

            g_form.setReadOnly('tier_confirmation', true);

        }

    }

—>And also Check if any existing ui policies on the field tier_confirmation which is making read only as false. It will take precedence always.

 

If my response helped, please mark it as the accepted solution and give a thumbs up👍.
Thanks,
Anand