I cant print values from a specific table in background script

samuelscott
Tera Expert

I'm running a background script where I want to compare some values from different tables before making any changes. I'm able to print values from one table but not from the other. This is my background script

 

var gr = new GlideRecord('sc_task');
gr.addQuery('short_description', "VMO signature attachment");
gr.query();

while(gr.next()){
	
	var br = new GlideRecord('sc_item_option_mtom');
	br.addEncodedQuery('sc_item_option.item_option_new.cat_item.name=Request a new service^sc_item_option.item_option_new.question_text=VMO Approves Date^sc_item_option.value!=NULL'); //vmo approves date
	br.addQuery('request_item', gr.request_item);
	br.query();
	gs.print("Row count: " + br.getRowCount() + ">>>>>" + "RITM Number: " + gr.request_item.getDisplayValue());
	if(gr.closed_at != br.sc_item_option.value){
		
		/*EVERYTHING I TRY TO PRINT FROM "br" query is printed as undefined (TRY log below)*/ 
		//gs.print("RITM Number: " + gr.request_item.getDisplayValue() + ">>>>>>" + "Task closed at: " + gr.closed_at + ">>>>>" + "VMO Approves Date Stamp: " + br.sc_item_option.value);
	}
}	

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi,

 

Include br.next(); after br.query();

 

-Pradeep Sharma

View solution in original post

3 REPLIES 3

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi,

 

Include br.next(); after br.query();

 

-Pradeep Sharma

samuelscott
Tera Expert

Thanks!

You are very welcome. Thanks for participating in the community!

 

-Pradeep Sharma