How to copy both work notes and additional comments in a field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2018 12:28 AM
Hi All,
We are using OOB Time Worked functionality on incident form So I would like to copy the latest Additional Comments /Work notes entered on Incident to comments field in Time worked table.
I wrote a before insert/update BR
var workNotes = current.task.work_notes.getJournalEntry(1);
var additionalComments = current.task.comments.getJournalEntry(1);
var dateRE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;
if(additionalComments){
current.comments = additionalComments.replace(dateRE, '');}
if(workNotes) {
current.comments = workNotes.replace(dateRE, '');
}
But it is updating either work notes or comments
If I first enter comments it is updating comments later if I enter worknotes it is still updating the last comments which i entered previously instead of the lates worknotes.
Please suggest where I am going wrong
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2018 12:35 AM
Try
var workNotes = current.task.work_notes.getJournalEntry(1);
var additionalComments = current.task.comments.getJournalEntry(1);
var dateRE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;
var comment;
if(additionalComments){
comment = additionalComments.replace(dateRE, '')+'\n';
}
if(workNotes) {
comment+= workNotes.replace(dateRE, '');
}
current.comments = comment;
Note Untested code.
-Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2018 12:54 AM
Hello,
Try the below script:-
if(current.comments.changes())
{
current.description=current.comments.getJournalEntry(1);//change your field name.
if(current.work_notes.changes())
current.short_description=current.work_notes.getJournalEntry(1);//change your field name.
}
Regards,
Mohammed Iqbal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2018 01:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2018 12:56 AM
Hi,
Try this code should solve your issue. It will set comments or worknotes based on the kind of info you are entering.
//Sample Code
var workNotes = current.task.work_notes.getJournalEntry(1);
var additionalComments = current.task.comments.getJournalEntry(1);
var dateRE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;
if(current.comments.changes && additionalComments){
current.comments = additionalComments.replace(dateRE, '');
}
if(current.work_notes.changes && workNotes) {
current.comments = workNotes.replace(dateRE, '');
}
-Regards,
Udhay