- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2021 04:33 AM
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:
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 :
Could you please help with scripting solution for this issue
Thank you
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2021 05:00 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2021 05:00 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2021 09:56 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2021 10:12 AM
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
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2021 05:20 AM
Use gs.isInteractive() in both the BRs condition