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

g_form.GetValue('field') returning a sys_id

ServiceNowSteve
Giga Guru

Evening All,

 

I am trying to get a display value from an incident form field using an onChange client script.

My current code:

	var client = g_form.getValue('company');
	alert("Client: " + client);

is returning a sys_id instead of the value and since client scripts don't support getDisplayValue I am at a loss. I've seen a bunch of different code snippets to get around this but non work on my Jakarta instance. 

Any idea how I can get this?

1 ACCEPTED SOLUTION

Ok. Looks like it works in Service portal but not on IT.

 

The other option is 

 

var comp = g_form.getReference('company', getCompany);

function getCompany(comp){

         alert(comp.name);

        }


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

9 REPLIES 9

Ok. Looks like it works in Service portal but not on IT.

 

The other option is 

 

var comp = g_form.getReference('company', getCompany);

function getCompany(comp){

         alert(comp.name);

        }


Please mark this response as correct or helpful if it assisted you with your question.

i'll be damned. I tried that code before and it didn't work but when I copied your version it did!

 

Thank you very much and have a great weekend!

Community Alums
Not applicable

This works great. Thanks.

sachin_namjoshi
Kilo Patron
Kilo Patron

g_form.DisplayBox('YOUR REFERENCE FIELD').value;

 

Please use this.

Regards,

Sachin

onChange script error: TypeError: g_form.DisplayBox is not a function function