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

Hi Janos,

Thanks, but I wasn't able to get your script to work neither. See screenshots below.

find_real_file.png

find_real_file.png

 

find_real_file.png

find_real_file.png

I don't see where Additional comments has been updated. I see an e-mail attached to the current record, but I see no Additional comments that have been generated from it. Maybe it is off-screen-shot, but not in-screen-shot. That is just a mail, not an Additional comment.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

try this

I consider you are saving the REQ once comments are changed and not using post button to submit comments

(function executeRule (previous, current) {

	var comment = current.comments.getJournalEntry(1);
	var gr = new GlideRecord("sc_req_item");
	gr.addQuery('request', current.getUniqueValue());
	gr.query();
	if(gr.next()) {
		gr.comments = comment;
		gr.update();
	}

})(previous, current);

Regards
Ankur

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

Hi Ankur,

Your script doesn't work when the requester replies via email but it does when the requester replies via the portal. This is probably the case with Saurav's and Janos' scripts. However, copying the comments from Req to Ritm when a requester replies via email is what I need help with. Sorry for leaving that out. I didn't think about that scenario since, right now, all of our users communicate via email.

Any ideas on how to resolve this for email replies?

- AJ

Hi,

Did you verify the BR runs when comments are updated via inbound?

Regards
Ankur

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