- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2018 04:27 PM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 02:06 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2018 06:04 PM
Greetings manu6!
It sounds like you might want to utilize a UI Policy with several conditions "OR"ed together. and a UI Policy Action which sets your hidden variable to visible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2018 07:41 PM
Hi Andrew,
The hidden variable is not an issue, it could be a visible field/variable on the form.
I just want to populate this field with a defined value "Yes" if any of the 10 reference fields has value "Auditor" in it.
Regards
Manu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2018 07:54 PM
I believe unfortunately we need 10 onChange() client script, since the onChange() client script trigger is tightly coupled with only field at a time, so one onChange() client will not know what changes are you going to make on other reference fields. as we are looking for instance result with onChnage() on field value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 02:06 PM
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