How to set choice values on form

Nag9
Tera Expert

Hi All, I have below business requirement

In my catalog form i have two variables 

1. Target number - which is reference to target table

2. Complaint - as select box(yes/no)

 

 if we select a target number in first variable as TGT1234(inside that " TGT1234 " form we have a field called "complaint " with data as 'test complaint')

 My question is 

if i select a target number in first variable and that number form has complaint field data i need to set the second variable complaint as yes and it should be read only.

 

if i select a target number in first variable and that number form has no complaint field data i need to set the second variable complaint as No and it should be read only.

 

 

How can we achieve this

 

 

 

 

 

14 REPLIES 14

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use onChange catalog client script with getReference() callback method

what have you tried so far?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Yes ankur i have tried but no luck, 

 

how to identify whether that target number form has complaint data or not?

 

if possible could you please provide a sample script so that i can try

please share your script

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

g_form.getReference('target_number', doAlert);

function doAlert(number) {
g_form.setValue('u_complaint', number.u_complaint_num);
g_form.setReadOnly('u_complaint',true);
}
//Type appropriate comment here, and begin script below

}