g_form.getReference(variable, callback function) showing undefined value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2019 12:31 PM
Hi,
I have created a new table new_line_of_business which contains a reference column lob_name to another table (cmdb_line_of_business) which has names field.
Now, in a catalog item, I have a variable 'lob' where I am referencing the new_line_of_business_table.
There is a variable 'access' in the catalog item where I have to display a prefix and Line of business name selected by the user-
Here is the onchange code -
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var a = g_form.getReference('lob', callBackFunc);
}
function callBackFunc(a)
{
var roleName = a.name + '-';
g_form.setValue('access', 'CP/HCV-'+roleName);
}
Now it is displaying undefined but it should show ecom. Can anyone help why this is happening?
In the referenced table , new_line_of_business, the lob_name col is referencing another table (I Tried making lob_name string also, it didn't work )
Please help.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2019 12:45 PM
I usually do mine something like this and it always works.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.getReference('lob', function(ref){
g_form.setValue('access', 'CP/HCV-'+ref.name+'-');
});
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2019 01:04 PM
I dont see thats an OOB table. So you field name must be different. check if the field name in new_line_of_business_table is u_name.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var a = g_form.getReference('lob', callBackFunc);
}
function callBackFunc(a)
{
var roleName = a.u_name + '-';
g_form.setValue('access', 'CP/HCV-'+roleName);
}
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
09-18-2019 12:37 AM
Hi Sanjiv, the name was wrong, it worked but it shows CP/HCV-b6280184db000010ce217b603996197f- sys_id instead of the name. Is this because the new_line_of_business table has the u_name as reference field to another table?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2019 12:39 AM
use glide ajax here to get the display value .