Query sc_req_item

JLeong
Mega Sage

Hello,

I need to query sc_req_item from sc_task,   I tried different combinations but I could not make it to work. Could someone please assist.

var current_cat_task = g_form.getValue('number');

var gr = new GlideRecord('sc_req_item');

gr.addQuery('sys_id',current_cat_task );

gr.query();

while (gr.next()) {

alert('Query working');

}

i also tried.....

var gr = new GlideRecord('sc_req_item');

gr.addQuery('sys_id',current.parent);

gr.query();

while (gr.next()) {

alert('Query working');

}

Thank you!

1 ACCEPTED SOLUTION

phillipkeigley
Kilo Expert

Hi Jocelyn,



If your on the sc_task, for example calling this script onLoad, you would want to query the sys_id of the sc_req_item which is on the sc_task form in field "request_item".



Here you go:



var req_itm =g_form.getValue('request_item');


var gr = new GlideRecord('sc_req_item');


gr.addQuery('sys_id',req_itm);


gr.query();


while (gr.next()) {


alert(gr.number + ' - '+ gr.short_description);


}


View solution in original post

2 REPLIES 2

phillipkeigley
Kilo Expert

Hi Jocelyn,



If your on the sc_task, for example calling this script onLoad, you would want to query the sys_id of the sc_req_item which is on the sc_task form in field "request_item".



Here you go:



var req_itm =g_form.getValue('request_item');


var gr = new GlideRecord('sc_req_item');


gr.addQuery('sys_id',req_itm);


gr.query();


while (gr.next()) {


alert(gr.number + ' - '+ gr.short_description);


}


Thank you Phillip!!! It is working now!