how can i get RITM number when i query on sc_request table

ram m1
Kilo Contributor

Hi All,

i need to write gliderecord query on req table and based on that i need to get RITM number for that Req.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

that's correct

something like this

var gr = new GlideRecord("sc_req_item");
gr.addQuery("request.number", "REQ19101");
gr.query();
if (gr.next()) {
   gs.info("RITM" + gr.number);
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

that's correct

something like this

var gr = new GlideRecord("sc_req_item");
gr.addQuery("request.number", "REQ19101");
gr.query();
if (gr.next()) {
   gs.info("RITM" + gr.number);
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Aman Kumar S
Kilo Patron

Hey,

I think the relationship between Request and Requested item is established on Requested Item form with Request reference field.

So if you want to check which RITMs are associated with my Request, you will need to glide the RITM table:

var ritmGR = new GlideRecord("sc_req_item");
ritmGR.addQuery("request", current.getUniqueValue());// this works if you are writng BR on request table, this will pass sys_id of the req to the query
ritmGR.query();
while (ritmGR.next()) {
   gs.info(ritmGR.getValue("Number"));// this will give sys_ids of RITM, you can mention number if you want to see numbers
}
Best Regards
Aman Kumar