Fetch display values in a catalog client script

Khanna Ji
Tera Guru

How to fetch display values from catalog items in a client script? I have a requirement where I have to find all the catalog item variables inside a catalog and send them to endPoint for whatever the values that users enter in the form before the form is submitted.

I extracted all variables for the current catalog and I was able to get the values but for reference/choice fields its returning sys_ids and internal value.

How can I achieve this? I want to send the  display values, not sys_ids.

1 ACCEPTED SOLUTION

Hi,

it would work on native

can you try this

g_form.getDisplayValue('variableName')

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

try this

g_form.getDisplayBox('variable').value;

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

It's giving java script error in the browser on the Service Portal.

Hi,

it would work on native

can you try this

g_form.getDisplayValue('variableName')

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hello,

Try the getReference with callback function.

 

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}

	g_form.getReference('reference_for', doAlert); // doAlert is our callback function

	function doAlert(reference_for) { 
		alert('User: ' + reference_for.name);

	}	
}

 

Thanks,

Sagar Pagar

The world works with ServiceNow