Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Dot walk to CI class field

Brian Lancaster
Kilo Patron

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

Ahh that is probably the reason, you are using getReference on a field that is reference to the cmdb_ci table. And the field you want to get isn't on that table, but on an extended table. That means that when you query the record from cmdb_ci, you won't get back that field, only the field that exist in the cmdb_ci table.

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

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 

That is what I figured but just wanted to see if there was a way to do it.