How can I query a request number with the sc_req_item table?

PaKe
Kilo Sage

Hello,

I need to show the requested items with a certain request-number. Therefore I query the sc_req_item table. Here is my code, but I don't know what is the right name for the field with the request-number:

var gr = GlideRecord('sc_req_item');
gr.addOuery('Request', current.request.number);
gr.query();
while(gr.next()){
	template.print(gr.number);
	template.print(gr.cat_item.name);
	template.print(gr.cat_item.price);
} 

Hopefully somebody can help me. Thanks in advanced!

1 ACCEPTED SOLUTION

Chuck and I have both copied your code and amended it, looks like you've miss-spelled Query in the addQuery line and neither of us have picked up on it!

Try this out:

 

var gr = GlideRecord('sc_req_item');
gr.addQuery('request', current.request);
gr.query();

while(gr.next()){
 	template.print(gr.number);
	template.print(gr.cat_item.name);
	template.print(gr.cat_item.price);
} 

View solution in original post

11 REPLIES 11

Dubz
Mega Sage
var gr = GlideRecord('sc_req_item');
gr.addOuery('request', current.request);
gr.query();
while(gr.next()){
	template.print(gr.number);
	template.print(gr.cat_item.name);
	template.print(gr.cat_item.price);
} 

Unfortunately I get all requested items

All?! Try adding some logs lines

gs.log('this is the request: ' + current.request.getDisplayValue());
var gr = GlideRecord('sc_req_item');
gr.addOuery('request', current.request);
gr.query();
gs.log('found ' + gr.getRowCount() + ' records');
while(gr.next()){
gs.log('this is the ritm: ' + gr.getDisplayValue() + ' and the request: ' + current.request.getDisplayValue());
 	template.print(gr.number);
	template.print(gr.cat_item.name);
	template.print(gr.cat_item.price);
} 

I have already tried some log lines. current.request.number has the right value. There have to be an error with the name of the request field.