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

@ServiceNow User 

Try this updated Script

1) Ensure Isolate Script field is set to false for your client script

2) This field is not on form but from list you can make it false

Example: my variable is reference to sys_user table

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

	if(window == null){
		var valuePortal = g_form.getDisplayValue('requester');
		alert('Portal->' + valuePortal);
	}
	else{
		var valueNative = g_form.getDisplayBox('requester').value;	
		alert('Native->' + valueNative);
	}

	//Type appropriate comment here, and begin script below

}

find_real_file.png

Output:

Native:

find_real_file.png

Portal:

find_real_file.png

Regards
Ankur

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