How to get RITM and Task values for each Request?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 03:22 AM
Hi All,
The below Request('sc_request") contains two RITM's("sc_req_items") and each RITM will have a Task number("sc_task").
I want to display the both RITM number and Task number by using the Request('sc_request") number.
Please share your ideas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 04:19 AM
Hi
The aim is to to pass ('sc_request") number and get the Task number("sc_task").
How to get this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 04:22 AM
Hi,
In the above script arr1 will give all the tasks associated with the request.
Regards,
Ram M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 04:26 AM
I have a query from where I have to pass REQ sys_id and RITM sys_id??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 04:36 AM
Hi,
You need to pass only the request sys_id and no need to pass for RITM as from the request itself we are getting the RITM details. Please find the below marked one where we are passing the sys id of the request. BR to be created on Request table else you need to change the current.sys_id :
var arr = [],arr1 = [];
var req = new GlideRecord("sc_req_item");
req.addEncodedQuery("request=" + current.sys_id);
req.query();
while(req.next())
{
arr.push(req.number.toString());
var task = new GlideRecord("sc_task");
task.addEncodedQuery("request_item=" + req.sys_id);
task.query();
while(task.next())
{
arr1.push(task.number.toString());
}
}
gs.print("Request Number : " + current.number);
gs.print("Requested Item Number(s) : " + arr);
gs.print("Task Number (s): " + arr1);
Regards,
Ram M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 05:04 AM
Hi,
Kindly use this script portion wherever you want to extract the results:
var reqs="6eed229047801200e0ef563dbb9a71c2";
var req=[];
var gr=new GlideRecord('sc_req_item');
gr.addQuery('request',reqs);
gr.query();
while(gr.next()){
req.push(gr.getValue("number"));
gs.log("that is the RITMs:"+req); //the RITM present in requests
for(var i=0;i<=req.length;i++){
var tsk=[];
var gr1=new GlideRecord('sc_task');
gr1.addQuery('request_item.number',req[i]);
gr1.query();
while(gr1.next()){
tsk.push(gr1.getValue("number"));
gs.log("that is the tasks:"+tsk); // //the TASK present in requests
}
}
}
Regards,
Munender
**Kindly hit correct/helpful if sound useful