Copy Additional Comments from Request to RITM

TStark
Kilo Sage

Can anyone provide some insight on the proper script for the Business Rule that will allow Additional Comments created on the Request to automatically copy to the RITM? I tried using the following with no luck.

Create an after business rule on sc_request table

-When: after insert and update
-Conditions: Additional comments changes
-Script:

var gr= new GlideRecord("sc_req_item");


gr.get(current.getValue("request_item"));


gr.comments=current.comments.getJournalEntry(1);


gr.update();

Thanks,
AJ

1 ACCEPTED SOLUTION

Saurav11
Kilo Patron
Kilo Patron

Hello

var gr = new GlideRecord('sc_req_item'); gr.addQuery('request',current.sys_id);

gr.query(); while(gr.next())

{

gr.comments = current.comments;

gr.work_notes = current.work_notes;

gr.update();

}

Please mark answer correct/helpful based on impact

View solution in original post

17 REPLIES 17

Saurav11
Kilo Patron
Kilo Patron

Hello

var gr = new GlideRecord('sc_req_item'); gr.addQuery('request',current.sys_id);

gr.query(); while(gr.next())

{

gr.comments = current.comments;

gr.work_notes = current.work_notes;

gr.update();

}

Please mark answer correct/helpful based on impact

TStark
Kilo Sage

Thanks Saurav, but that didn't work. I'm not sure if your script was for the Additional Comments for the RITM, but I need from the Additional Comments on the Request to copy to the Additional Comments on the RITM.

Thanks,
AJ

Saurav's strategy should be OK, just modify it to use your method to get the last comment. In an after Business Rule the comment is empty.

E.g:

(function executeRule (previous, current) {
	var comment = current.comments.getJournalEntry(1);
	var gr = new GlideRecord("sc_req_item");

	gr.addQuery('request', current.getUniqueValue());

	gr._query();

	while (gr._next()) {
		gr.comments = comment;
		gr.update();
	}
})(previous, current);