Ankur Bawiskar
Tera Patron
Tera Patron

Many a times there is a need to get the display value of reference variable on native or portal for Service Catalog for some validation or alert/field messages..

There are couple of questions and solutions around this. But I thought to create a blog considering both Native & Portal view in mind.

So here is the way to handle it in both Native + Portal view

1) Create Catalog Client Script on the reference variable of type onChange/onSubmit etc

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

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

Note: The solution requires this Isolate Script field as false considering the window object in script being used

Example: my variable "requester" 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

Thanks for reading the blog and do provide your inputs/suggestions if any.

Hope you find this article helpful. Don’t forget to Mark it Helpful & also Bookmark it.
Thanks,
Ankur Bawiskar

ServiceNow MVP 2020,2019,2018

My Articles & Blogs

 

 

7 Comments