Populate variable value based on reference fields common value

manu61
Mega Contributor

On my service catalog form there are 10 reference fields which all points to same table.

Ref 1, Ref 2............Ref 10.

If any of the above reference field has a value AUDITOR then there is another field on the form to populate Yes, otherwise populate No (default).

The problem is that when I write one onChange catalog client script it gets applied to one reference field only.

How I can do it for all 10 reference fields in one script? Does that mean I have to write 10 onChange client script for each Reference variable?

The simple catalog client script for one reference variable (Ref1) is:

function onChange(control, oldValue, newValue, isLoading){

if (isLoading){

return;

}

if (newValue == "91e885c6db5b07705e90ddb85e9620s9"){   //sys_id of AUDITOR value from reference table

g_form.setValue('hidden_variable','Yes');

}

else

g_form.setValue('hidden_variable','No');

}

How I can accomplish the above scenarios for 10 ref. variables in one client script?

1 ACCEPTED SOLUTION

manu61
Mega Contributor

Hi Andrew


Thanks for your guidance. I have used a UI Policy with conditions "OR"ed together for all 10 Reference variables and in the script part I added g_form.setValue('hidden_variable','No'); on Execute if false and g_form.setValue('hidden_variable','Yes'); on Execute if true.



Best Regards


Manu


View solution in original post

5 REPLIES 5

Nate23
Mega Guru

if this hidden field drives any other functionality on the form you can just ignore this thought, but you could just do an onSubmit client script that checks all the ref fields and changes it to yes if Auditor is there.