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

@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

Hi @abc1233 

 

Then you can use a background script for this:

 

var ritms = new GlideRecord('sc_req_item');
ritms.addQuery('request.description', '');
ritms.query();
while (ritms.next()){
var requestRecord = GlideRecord('sc_request');
if (requestRecord.get(ritms.getValue('request'))){

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

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