The CreatorCon Call for Content is officially open! Get started here.

Catalog Client Script Dot Walk

ceraulo
Mega Guru

Hello!

I have a catalog client script shown below. It aims to get the region of the location variable from the cmn_location table.
My script returns undefined when I used getDisplayValue. If I remove getDisplayValue, it returns the sys_id.

function onLoad() {

    var loc = g_form.getValue('var_loc');
	
    var gr = new GlideRecord('cmn_location');
    gr.addQuery('sys_id', var_loc);
    gr.query(myCallbackFunction);

    function myCallbackFunction(gr) {
        while (gr.next()) { 
			
			alert(gr.u_region.getDisplayValue());

        }
    }

}

Please help!

Thank you.

12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

@ceraulo 

You cannot use getDisplayValue in client side

So either use GlideAjax based approach or have 1 more query with GlideRecord

Regards
Ankur

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

@ceraulo 

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

If not, please let us know if you need some more assistance.

Thanks!
Ankur

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

@ceraulo 

Hope you are doing good.

Did my reply answer your question?

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Thanks!
Ankur

 

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