Set Display Value on Catalog Client Script - not sys_id

Henrik Jutterst
Tera Guru

I have this client script that's running when ever a serial number is changed. What I'm looking for is to set the model name to the text field. But the scipt returns the sys_id instead of the Dispaly value.

I've seen some posts here but I'm missing the last piece to understand.

Here's my Catalog UI Script:

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

	var grSerialNumber = new GlideRecord('cmdb_serial_number');
	var snSysID = g_form.getValue('serialNR');
	grSerialNumber.addQuery('sys_id', snSysID);
	grSerialNumber.query(myCallbackFunction);
	g_form.addInfoMessage(snSysID);


	function myCallbackFunction(gr) {
		while (gr.next()) {
			//set Display Value to model filed
			g_form.setValue('model', gr.cmdb_ci);
		}
	}
}
7 REPLIES 7

Yes, that is another benefit of using the script include. In the script include you can use dot walking.

That's great! I'll give it a go tomorrow but I'm sure this is the way to go!

I'll keep you (the thread) posted.

Hi Henrik,

Did this resolved your question?

If not, please let us know how we can be of further assistance.

Kind regards,

Willem