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

SanjivMeher
Kilo Patron
Kilo Patron

Did you try g_form.getDisplayBox('company')


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

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

Sorry it is g_form.getDisplayBox('company').value


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

same error