
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 10:39 AM
Hello SN Community!
So, I've created a custom table which stores field1 and the associated field2 value to be used on a Service Portal page. Now, I'm trying to a use the value that the user selects for field1 to get and display the value of field2. What is the best way to do this in an onChange client script? I'm looking for best practices and possible samples, please....
Thanks in advance!
Maria.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 11:06 AM
Hi Maria,
Write an onchange Client script on field A;
Use g_form.getReference('field_name',callback) to get the server side value.
Update field_2 from the custom table field name which stores (111) value and feild 2 in which you need to stores.
var g = g_form.getReference('fieldA',callback);
function callback(a){
g_form.setValue('field2',a.field_2);//Update field_2 with the field which stores 111 in yourcustom table
}
Mark helpful and correct if it helps.
Thanks,
CB

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 10:45 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 11:00 AM
Hello Pranav,
Thanks for the reply.
However, I'm not trying to set the value of field2, I'm trying to get the value depending on field1 from my custom table.
For example, if my custom table has the following entries
field1 field2
TSA 203
PCA 111
BAP 764
So, if the user selects PCA for the field1 value on the form, then I want the other value to be set/display to 111 automatically.
I hope you can help me...
Maria.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 11:06 AM
Hi Maria,
Write an onchange Client script on field A;
Use g_form.getReference('field_name',callback) to get the server side value.
Update field_2 from the custom table field name which stores (111) value and feild 2 in which you need to stores.
var g = g_form.getReference('fieldA',callback);
function callback(a){
g_form.setValue('field2',a.field_2);//Update field_2 with the field which stores 111 in yourcustom table
}
Mark helpful and correct if it helps.
Thanks,
CB

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2020 05:17 AM
Hi CB!
Thanks for the reply. I thought this was the correct way of doing it. However, my field2 (assignment_group) is still coming up empty on my page and I'm not sure why. Here's my code:
var appl = g_form.getReference('application',callback);
function callback(appl){
g_form.setValue('assignment_group',appl.support_group);
}
}
My assignment group field is defined as a reference field to the sys_user_groups table. And all the values in the appl.support_group field are in the sys_user_groups table.
I even tried to do an alert to see what the return value was for appl.support_group and it was shown as 'undefined'.
Maria.