- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2021 10:24 AM
I have been working on several on-change client scripts to make this work, but have so far been unsuccessful. The task to make two fields that share the same table populate with their respective values, based-on the value of another field from the same table.
Below, is my script include.
How do I go about writing an on-change CS to make this work?
Thank you!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2021 03:41 PM
This is what I have defined in my PDI:
HHave added the fields to the Change Request form:
After flushing the cache, when I change System, Analyst and Owner automatically update.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2021 10:42 AM
Hi
You can do this with on change client script only. No need of Script include.
Try below once. Please change fields names correctly
Onchange client script on System field.
var selected_value = g_form.getReference('system', myCallBack);
function myCallBack(selected_value) {
g_form.setValue('owner',selected_value.owner);
g_form.setValue('analyst',selected_value.analyst);
}
Hope this helps
Thank you
Prasad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2021 12:14 PM
Hi
Glad that you find it helpful.
Did my reply answer your question?
If so, can you please mark response as correct for others who may have a similar question in the future.
If not, please let us know if you need any other help
Thank you
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2021 12:20 PM
This is what I incorporated into my instance.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var selected_value = g_form.getReference('system', myCallBack);
function myCallBack(selected_value) {
g_form.setValue('owner',selected_value.u_system_owner);
g_form.setValue('analyst',selected_value.u_analyst);
}
}
Unfortunately, it does not return any values when system changes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2021 12:26 PM
Have you added correct field names for 'system', 'owner' and 'analyst'
It should be exact logical names of your fields

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2021 12:27 PM
This should be your field names.
Also onchange field should be System in client script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var selected_value = g_form.getReference('system', myCallBack);
function myCallBack(selected_value) {
g_form.setValue('owner',selected_value.u_system_owner);
g_form.setValue('analyst',selected_value.u_analyst);
}}