g_form.getReference(variable, callback function) showing undefined value.

prabhmeet
Giga Expert

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);
}

find_real_file.png

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.

6 REPLIES 6

Brian Lancaster
Tera Sage

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+'-');
	});
	
}

SanjivMeher
Kilo Patron
Kilo Patron

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.

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?

 

use glide ajax here to get the display value .