How to fetch data from sc_request table using RITM number?

Anuja Jadhav1
Tera Contributor

There is one  scenario in my project where I am getting RITM number based on that I need to fetch 

Short description from Request table using script .
3 REPLIES 3

Prabu Velayutha
Mega Sage
Mega Sage

You can try this below script. Please mark it correct if it fulfills the requirement

var item = new GlideRecord('sc_req_item');
item.addQuery('number','RITMNumber');
item.query();
if (item.next()){
var req = item.getValue('request');
}
var request = new GlideRecord('sc_request');
request.addQuery('sys_id',req);
request.query();
if (request.next()){
var req2 = item.getDisplayValue('short_description');
gs.info(req2);
}

Hemant Goldar
Mega Sage
Mega Sage

Hi @Anuja Jadhav1,

 

Please find the below link it will help you to resolve your issue.

https://www.servicenow.com/community/itsm-forum/how-can-i-get-ritm-number-when-i-query-on-sc-request... 

 

I hope this helps!

 

Regards,

Hemant 

**Please mark my answer correct or helpful based on the impact**

Ankur Bawiskar
Tera Patron
Tera Patron

@Anuja Jadhav1 

where are you writing the script?

Sample script

var item = new GlideRecord('sc_req_item');
if(item.get('number','RITMNumber')){
	var reqObj = item.request.getRefRecord();
	var shortDescription = reqObj.Value('short_description');
	gs.info(shortDescription);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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