
- 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:46 AM
Hi Karen,
Your Clarity # field should be a reference field to clarity project info table
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2017 10:32 AM
I tried what you said which was to make all of the fields in the screenshot below reference field because they all come off of the clarity project info table, but i am not sure what is happening. It appears that it is loading some information because the mandatory fields are NO LONGER mandatory but i can't see the values. It's almost like they are whited out or something.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2017 10:43 AM
Hi Karen,
If the Project Manager is a reference field, in the change record, it should be a reference field to user table in catalog as well.
If Project Name is a string field in change record, use the same data type.
Application/Technical Manager will also be a reference field and point to User table.
Clarity will be the referenece to the clarity record.
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);
g_form.setValue("project_manager", clarity_project_info.u_project_manager);
g_form.setValue("project_name", clarity_project_info.U_project_name);
g_form.setValue("tech_manager_field", clarity_project_info.tech_manager_field);
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2017 11:22 AM
So Sanjev,
If I am understanding you correctly. I did the following
Clarity Number - I made it a single line text field. It is defined as a string in the clarity project info table
Project Manager - I made a reference field (referencing the user table)
Project Name - I made a single line text field, It is defined as a string in the clarity project info table
Technical Manager - I made a reference field (referencing the user table). That is how it is defined in the clarity_project_info_table.
I updated the script as follows but still getting the same response. It looks like it entered the information but I can't see anything. If I click the magnifying glass next to the reference field I do get a list of name of id #'s; however it is just not showing on the form.
function onChange (control, oldValue, newValue, isLoading) {
if (newValue == ''){
g_form.setValue("vdb_proj_name", "");
g_form.setValue("vdb_proj_mgr", "");
g_form.setValue("vdb_app_tech_mgr", "");
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_proj_name", clarity_project_info.u_project_name);
g_form.setValue("vdb_proj_mgr", clarity_project_info.u_project_manager);
g_form.setValue("vdb_app_tech_mgr", clarity_project_info.u_technical_delivery_manager);
g_form.setValue("vdb_clarity_num", clarity_project_info.u_id);
}