Copy RITM description to REQ description

abc1233
Tera Contributor

Hi Team,

When revieiwing the list of active REQ tickets, the Description field is empty.
This needs to be populated based on what was input by the user, taking the information from  Description  field of the associated RITM ticket.

1 ACCEPTED SOLUTION

@abc1233 

then use background script to update those REQ

something like this

updateRecords();

function updateRecords(){
	try{
		var req = new GlideRecord('sc_request');
		req.addEncodedQuery('descriptionISEMPTY');
		req.query();
		while(req.next()){
			var ritm = new GlideRecord('sc_req_item');
			ritm.addQuery('request', req.getUniqueValue());
			ritm.query();
			if(ritm.next()){
				req.description = ritm.description;
				req.update();
			}
		}
	}
	catch(ex){
		gs.info(ex);
	}
}

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

View solution in original post

6 REPLIES 6

ServiceNow Use6
Tera Guru

Please use Business Rule

 

(function executeRule(current, previous /*null when async*/) {


   // Add your code here


   var sc = new GlideRecord('sc_req_item');


   sc.addQuery('sys_id', current.request_item);


   sc.query();


   while(sc.next()) {


   current.short_description = sc.short_description;


   current.update();


   }



})(current, previous);

 

https://www.servicenow.com/community/itsm-forum/copy-ritm-description-to-request-and-task/m-p/884900

 

Regards

Suman P.

Peter Bodelier
Giga Sage

Hi @abc1233,

 

There are multiple ways to do that, easiest is probably to use a Business rule which is triggered on the insert of a RITM.

var requestRecord = GlideRecord('sc_request');
if (requestRecord.get(current.request.sys_id)){

requestRecord.setValue('description', current.description);
requestRecord.update();
}

 

But keep in mind that Request can potentially have multiple RITMs associated to them.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Ankur Bawiskar
Tera Patron
Tera Patron

@abc1233 

what happens when REQ have multiple RITMs belonging to different catalog items?

you can use workflow run script for this if this is required only for 1 catalog item

var req = current.request.getRefRecord();
req.description = current.description;
req.update();

OR

you can also use flow designer Update Record action if you are using flow only for 1 catalog item

OR
you can use after Insert BR on RITM if you want to do this for all catalog items

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

Hi @Ankur Bawiskar / @Peter Bodelier ,

Thanks for your response, but I want While  reviewing the list of active REQ tickets, the Description field to be updated (Description should be same as description of RITM)

abc1233_0-1696353826464.png