How to copy both work notes and additional comments in a field

sk59
Tera Expert

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

 

17 REPLIES 17

Mohammed_Iqbal
Tera Guru

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

 

James Brown2
Kilo Explorer

AS far as the YouTube video, attempt using the "Embed" URL.  So from the website online for your video, click on "Share" then "Embed", then choose the URL from within the quotations:

James Brown2
Kilo Explorer

AS a ways because the YouTube video, attempt using the "Embed" URL. So from the net website online online on your video, click on "Share" then "Embed", then pick out the URL from in the quotations.