Query Request Item Detail from Catalog Task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2013 02:09 PM
Hello,
I would like to update some fields in our Catalog Tasks with detail information from the request values.
For example, we have some Catalog Tasks (sc_task) that we want to update the Short Description and Description values with data in the request items (sc_item_option_mtom).
Is there a way to query from sc_task to sc_item_option_mtom and then update back onto sc_task?
Here is the code I have got so far:
var gr = new GlideRecord('sc_task');
gr.addQuery('assignment_group','d77c144f2b47308407ba65dee8da156d');
gr.addQuery('state','!=', 3);
gr.addQuery('state','!=', 4);
gr.query();
gs.print('TASK ' + gr.number);
//gr.addJoinQuery('sc_item_option_mtom');
//gr.query();
while (gr.next()){
gs.print('TASK ' + gr.number);
var rec = new GlideRecord('sc_item_option_mtom');
rec.addQuery('request_item', gr.sys_id);
rec.query();
gs.print('ITEM ' + rec.sys_id);
}
gs.print(gr.getRowCount());
Thanks for your help!
Mark Didrikson

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2013 08:17 PM
There are better ways to do this, but those tables are pretty buried... here's a script to return the questions per task, however, the variables are pert sc_req_item not task...
Maybe this example will help you achieve what you're trying to do.
var task = new GlideRecord('sc_task');
//task.addQuery('assignment_group', 'd77c144f2b47308407ba65dee8da156d');
//task.addQuery('state', '!=', 3);
//task.addQuery('state', '!=', 4);
task.query();
while (task.next()) {
var mtom = new GlideRecord('sc_item_option_mtom');
mtom.addQuery('request_item', task.request_item);
mtom.query();
while (mtom.next()) {
gs.log('Task# ' + task.number + '/' + task.request_item.getDisplayValue() + '/Question:'+mtom.sc_item_option.item_option_new.question_text + '/Answer:'+mtom.sc_item_option.value);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2013 05:22 AM
Thanks for the response Jace. I ended up using a Business Rule to accomplish this update and it worked out quite nicely.
Mark Didrikson