- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 07:03 AM
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!
Solved! Go to Solution.
- Labels:
-
Notifications
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 07:44 AM
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 07:44 AM
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 07:51 AM
Oh my god! *facepalm*
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 07:52 AM
😂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 09:56 AM
We've all been there. Sometimes a second set of eyes is all it takes. Kudos to David for spotting that one. It was well hidden.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 07:07 AM
Based on the fact that you are using template.print(), I'm going to assume this is in a mail script somewhere.
At first glance, I'd say, change your 'Request' field to 'request'. I also added a little error checking in case the parent request reference is empty to avoid a null pointer exception and an additional template.print() to tell you how many items to expect from this query.
if (current.request) {
var gr = GlideRecord('sc_req_item');
gr.addOuery('request', current.request.number);
gr.query();
template.print(gr.getRowCount() + ' items found');
while(gr.next()){
template.print(gr.number);
template.print(gr.cat_item.name);
template.print(gr.cat_item.price);
}
} else {
template.print('No parent request found.');
}