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.

Getting Variable Value from RITM using Item Option table

Steven Parker
Giga Sage

Looking for some help.  I am just testing something and have a script to try and grab the variable values from an RITM.

 

 

//Just testing - RITM Sys ID
var ritmSysID = '413300509730ed10145b3b6e6253af31';

var gr = new GlideRecord('sc_item_option_mtom');
gr.addQuery('sc_item_option.item_option_new','e118bfd5db22bb00c53974dfaa96197a'); //Gap Owner Review Details Variable
gr.addQuery('request_item',ritmSysID);
gr.query();
if (gr.next()) {
		alert("GAP OWNER REVIEW DETAILS: " + gr.sc_item_option.value);
}

 

 

 

I keep getting 'undefined' no matter what I try to do (and I've tried a lot).  Now, if I add 'gr.request_item' in the Alert it returns the correct RITM SYS_ID so I know I am connected to the correct record.  I just want to get the 'gap_owner_review_detail' variable value.

 

Any help?


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
8 REPLIES 8

Brad Bowman
Kilo Patron
Kilo Patron

Have you tried doing the GlideRecord on the sc_req_item table, then using this syntax in your alert?

 

 gr.variables.gap_owner_review_detail

I have yes, but also returns undefined.


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

Are you running this as a Fix Script, or ...?

This is a Client Script and yes I know GlideRecord is not best practice there, but I am just testing something before going down the GlideAjax/Script Include path.  

 

I even tried doing a callback function which gives me the RITM Sys ID, but doesn't allow me to see the variables.

 

var ritm = g_form.getReference('request_item',func);
	function func(ritm)
	{
		if(ritm){
			var ritmSysID = ritm.sys_id;
}
}

 

I still couldn't use ritm.variables.gap_owner_review_detail.  I actually thought that would work as well to no avail.


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