Modify the comment for case record

Rosy14
Tera Guru

Hi,

 

I have a flow. when a case record approval is rejected the case is getting closed and the rejection comment from approval is added to case. but in comment the name and timestamp also showing. i want to show only the comment how to achive?

i tried a business rule .. but it is showing empty.

how to do inside flow or by business rule.

Rosy14_0-1719331501996.png

 

 

Rosy14_1-1719331547530.png

Rosy14_2-1719331577326.png

 

 

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

	// Add your code here
	var gr = new GlideRecord("sysapproval_approver");
	gr.addQuery("document_id", current.sys_id);
	gr.addQuery("state","rejected");
	gr.query();
	var comm;
	while(gr.next()){
		gs.addInfoMessage(gr.comments);
		comm =gr.getValue("comments");
	}

	current.comments = "The request has been updated by the approval team. Approval state: "+comm.getJournalEntry(1).split('\n')[1];
	current.update();

})(current, previous);

 

 

 

1 ACCEPTED SOLUTION

SN_Learn
Kilo Patron
Kilo Patron

Hi @Rosy14 ,

 

Please try the below piece of code, which will remove both the time stamp and user detail.

current.comments.getJournalEntry(1).match(/\n.*/gm).join("\n");

 

Please mark the answer as correct/helpful based on impact.

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

6 REPLIES 6

Please share the whole code to debug further.

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

@Rosy14 , You have to return the string rather than the Journal. This will resolve it.

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.