Dot walk to CI class field

Brian Lancaster
Tera Sage

I'm doing a g_form.getReference on the cmdb_ci field in a client script for incidents.  I'm trying to dot walk to a specific filed that is part of a specific class.  The filed is only on this class and when I do ci.u_service_level I get undefined.  What do I need to add to be able to get that field thought a dot walk via script?  Or am I going to have to do a GlideRecord query?  Below is my script.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}
	//Type appropriate comment here, and begin script below
	g_form.getReference('cmdb_ci', function(ci){
		if (ci.sys_class_name == 'u_cmdb_ci_myclass'){
			alert(ci.u_service_level);
		}
	});
}
1 ACCEPTED SOLUTION

And I  would recommend doing a GlideAjax call fore this as well to make sure you get the information you really want.

//Göran
Feel free to connect with me:
LinkedIn & Twitter
Subscribe to my YouTube Channel
Buy The Witch Doctor's Guide To ServiceNow 

View solution in original post

7 REPLIES 7

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Hi Brian,

Dot-walking doesn't work with getReference since the client side only fetches the value that specific record has. it has no clue what values the dot-walked field has. This is one of the reasons ServiceNow doesn't recommend using it anymore. I think you will need a good old GlideAjax call here.

//Göran
Feel free to connect with me:
LinkedIn & Twitter
Subscribe to my YouTube Channel
Buy The Witch Doctor's Guide To ServiceNow 

But I can dot walk to the sys_class_name without issue otherwise my alert would never get called.  I have check other CIs that do not have that class and the alert does not appear.

I think I read it to fast, what you do isn't "dot-walk". Since Dot-walk usually means that you go to another record. Like if I have a incident record as current I can type current.caller_id and I'm not dot-walking, but current.caller_id.email is. Since then I need to go into the caller record to get the email address. The caller_id value is on incident. 

But your problem seems strange. if you use getDisplayValue, does that work?

//Göran
Feel free to connect with me:
LinkedIn & Twitter
Subscribe to my YouTube Channel
Buy The Witch Doctor's Guide To ServiceNow 

Where exactly do you want me to try getDisplayValue?  I notice when I try to search for incidents with the u_service_level = 3 I get the following in the encoded query so I'm not sure if there is special scripting I have to do for this or it will not work.

cmdb_ci.ref_u_cmdb_ci_myclass.u_service_level=3