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

Prana Krushna
Giga Guru

@Rosy14 Please use the below function and Mark this helpful if it works for you.

<code>
filterMessage(current.comments.getJournalEntry(1).toString());

function filterMessage(notes) {

    var msg = notes; //get last comment

    msg = msg.split('\n');

    msg.shift();

    msg = msg.join('\n');

    msg = msg.replace('[code]', "").replace('[/code]', "");

    msg = msg.replace(/^\s*[\r\n]/gm, "");

    return msg;

}
</code>

It is not working. I added a action in flow where I add script to get the comment. giving error.

invalid return type: com.glide.glideobject.Journal

Script:

(function execute(inputs, outputs) {
// ... code ...

    var comm = inputs.Comment;
    comm = comm.getJournalEntry(1).split('\n')[1];
    outputs.rejcomm = comm.toString();

})(inputs, outputs);

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.

I need to do through action script in flow designer. its giving error.

Rosy14_0-1719390953201.png