
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2017 09:36 AM
I need to auto-populate a value from a table to a catalog item. I've done this before, so I am not sure why this is not working.
So I have a catalog item that has a variable called RFC - which is a reference field referencing the change request table.
That table (the change request table) has a field called project id which references the clarity project info table (The variable name in the clarity project info table is called u_id) vs in the change request table (it is called u_project_id).
I wrote an onChange client script that says the below. What is weird is if I use the change request table to pull in the id #, it gives me the sys id instead of the actual number. I did make sure that at least one of the variables had a display value of "true". But if I use the clarity_project_info table to pull in the id # - then I get an undefined for the value.
Not sure what is going on here.
function onChange (control, oldValue, newValue, isLoading) {
if (newValue == ''){
g_form.setValue("vdb_clarity_num", "");
return:
}
var clarity_project_info = g_form.getReference('vdb_rfc',CallBack);
}
function CallBack(clarity_project_info) {
g_form.setValue("vdb_clarity_num", clarity_project_info.u_id);
}
Thanks,
Karen
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2017 09:54 AM
getReference is returning an object of a higher level table that does not have that field defined. You'll need to use a GlideRecord so that you get back the correct object. Please check the following code and modify if any syntax errors
var clarity_project_info = new GlideRecord('parent table name');
if (clarity_project_info.get(g_form.getValue('vdb_rfc'))) {
g_form.setValue("vdb_clarity_num", clarity_project_info.u_id);
}
Thanks
PS: hit correct/helpful...if it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2017 09:54 AM
getReference is returning an object of a higher level table that does not have that field defined. You'll need to use a GlideRecord so that you get back the correct object. Please check the following code and modify if any syntax errors
var clarity_project_info = new GlideRecord('parent table name');
if (clarity_project_info.get(g_form.getValue('vdb_rfc'))) {
g_form.setValue("vdb_clarity_num", clarity_project_info.u_id);
}
Thanks
PS: hit correct/helpful...if it helps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2017 10:14 AM
Thank you I am going to try this but the clarity_project_info is the parent table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2017 11:43 AM
I had to tweek it a little bit, but I got it working.
Thanks for the assistance.
Karen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2017 10:55 AM
Please set values of all reference fields individually. you can keep alert statements where ever you want see the actual values.