How to set value for a drop down list and make the field readonly

Kaushik Ghosh
Tera Contributor

There is one field where the value needs to be set as Break-fix and I need make the field read only. 

The field is for emergency change. I have written a onload client scrip for that field.

function onLoad() {
//Type appropriate comment here, and begin script below
if (g_form.getValue('type') = 'standard'){
g_form.setValue("u_reason_for_change", Break-fix);
g_form.setReadOnly("u_reason_for_change", true);
}
}

The code is not working for this field, could you please help to fix it?


1 ACCEPTED SOLUTION

Amit Gujarathi
Giga Sage
Giga Sage

HI @Kaushik Ghosh ,
I trust you are doing great.
Please refer below script for the same.

function onLoad() {
    if (g_form.getValue('type') == 'standard') {
        g_form.setValue("u_reason_for_change", "Break-fix");
        g_form.setReadOnly("u_reason_for_change", true);
    }
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



View solution in original post

5 REPLIES 5

Samaksh Wani
Giga Sage
Giga Sage

Hello @Kaushik Ghosh 

 

You have used single equals to in the if statement, you need to use double equals to :-

 

 

 

function onLoad() {
//Type appropriate comment here, and begin script below
if (g_form.getValue('type') == 'standard'){
g_form.setValue("u_reason_for_change", "Break-fix");
g_form.setReadOnly("u_reason_for_change", true);
}
}

 

 

 

Plz Mark my Solution as Accept , if you find it Helpful.

 

Regards,

Samaksh

Still the dropdown value is not coming and it is not also readonly.

Amit Gujarathi
Giga Sage
Giga Sage

HI @Kaushik Ghosh ,
I trust you are doing great.
Please refer below script for the same.

function onLoad() {
    if (g_form.getValue('type') == 'standard') {
        g_form.setValue("u_reason_for_change", "Break-fix");
        g_form.setReadOnly("u_reason_for_change", true);
    }
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Thanks it's working now