- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 09:07 AM
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.
(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);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 01:18 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 09:53 AM
@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>
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 01:05 AM
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 01:18 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 01:36 AM
I need to do through action script in flow designer. its giving error.