The CreatorCon Call for Content is officially open! Get started here.

Copy work notes/Additional comments from Incident to Incident task and vice versa

Indira8
Kilo Sage

Hi All, 

We have a requirement to copy worknnotes from Inc Task to Inc and also copy the Worknotes and Additional comments from the Incident to the Additional comments of the Incident Task. However, when tried on personal instance , there are redundant entries being populated on task as shown below: 

find_real_file.png

Is there any filter that we can apply in the Business rule script that is the comment is copied from TASK then it should not be copied again. 

 

There are currently 2 BRs running for copying comments from INC -> TASK :

 

find_real_file.png

 

Could you please help with scripting solution for this issue 

Thank you 

1 ACCEPTED SOLUTION

Voona Rohila
Mega Patron
Mega Patron

Hi indira

You need to add additional condition in BR to prevent it from copying recursively.

current.comments.indexOf('Worknotes added from incident') < 0;

check this article https://community.servicenow.com/community?id=community_article&sys_id=4750aecfdbf3d814fa192183ca961...

 

You don't need 2 BR's for worknotes & comments , you can use current.work_notes.changes() or current.comments.changes() in your single BR.

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

7 REPLIES 7

Voona Rohila
Mega Patron
Mega Patron

Hi indira

You need to add additional condition in BR to prevent it from copying recursively.

current.comments.indexOf('Worknotes added from incident') < 0;

check this article https://community.servicenow.com/community?id=community_article&sys_id=4750aecfdbf3d814fa192183ca961...

 

You don't need 2 BR's for worknotes & comments , you can use current.work_notes.changes() or current.comments.changes() in your single BR.

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Thank you Rohila it is working but could you let me know how the give the code in same BR for work notes and comments as well . 
Even the condition has to be given with &&? 

 

Thank you 

Hi Indira,

You can use below script in single BR for this:

When to run condition should be work notes changes or comments changes on Insert/Update.

 

var work_notes = current.work_notes.getJournalEntry(1);
var comments = current.comments.getJournalEntry(1);
var inc = GlideRecord('incident_task');
inc.addQuery('incident',current.getUniqueValue());
inc.query();
while(inc.next()){
if(current.work_notes.changes()){
if(work_notes.indexOf('Worknotes added from incident')<0){
inc.work_notes = 'Worknotes added from incident \n'+current.number+'\n'+work_notes;
}
if(current.comments.changes()){
if(comments.indexOf('Comments added from incident')<0){
inc.work_notes = 'Comments added from incident \n'+current.number+'\n'+comments;
}
inc.update();
}

 

Please correct if any typo mistake in script.

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Upender Kumar
Mega Sage

Use gs.isInteractive() in both the BRs condition