how to get most recent comment without date and who has entererd the comment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2023 09:22 PM
I have a requirement to get only the most recent comment from work notes field where we are entering the comments.
I need only comment not with date and who has entered the comment.Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2023 09:37 PM
Hi @Hareesha ,
Hope you are doing well.
Please refer below script.
var inc = new GlideRecord("incident");
inc.get("sys_id of incident");
var notes = inc.work_notes.getJournalEntry(1);
gs.log(notes);
var regex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;
gs.log(notes.replace(regex, ''));
Please mark this response as correct or helpful if it assisted you with your question.
Regards,
Harshal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2023 09:49 PM
Hi @Harshal Aditya ,
Thanks for your response. It not working. i am getting with date and who updated.
var lastcomment=current.comments.getJournalEntry(1);
var regex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;
var comment=lastcomment.replace(regex, '');
template.print(comment);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2023 01:31 AM
Hi @Hareesha,
Thanks for your update.
I tried with the same script in my PDI it's strange it's working for me.
Could you please share the complete script I guess its email notification script
Regards,
Harshal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2023 04:10 AM - edited ‎09-19-2023 04:55 AM
Hi,
I would mention to check the behavior when an incident is resolved by its related problem resolution.
Fix notes (HTML) field is copied as a comment between [code] [/code] tags and I'm afraid that these tags will appear as comment content. Regex should be reworked to replace that too.
Best regards,