- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 10:02 PM
Hi All,
I need some help on below requirement
I need to copy work-notes from Incident to Task but with the condition that all the work-notes should be copied only at the time of Task creation and later only recent work-notes should be copied.
-Tahzeeb
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2020 09:35 PM
Hi Tahzeeb,
Are you trying this logic on HR Case and HR Task table? If yes, please follow the below screenshots on Human Resources : Core Scope.
1. BR on HR Case table:
2. BR on HR Task Table
Expected Results:
HR Task:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2020 09:34 AM
Hi,
So in this case you would require before insert business rule on incident_task table
Also you would require after update BR on incident table to copy work notes from incident to incident task
1) BR: Before Insert on incident_task;
Condition: Incident is not empty
Script:
current.work_notes = current.parent.work_notes.getJournalEntry(-1);
2) BR: After Update on incident
Condition: Work notes changes
Script:
var incTask = new GlideRecord('incident_task');
incTask.addQuery('parent', current.getUniqueValue());
incTask.query();
while(incTask.next()){
incTask.work_notes = current.work_notes.getJournalEntry(1);
incTask.update();
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2020 01:28 AM
Hi Tahzeed,
For the first time, your Business Rule will be 'Before','Insert' on 'incident_task' table
For the next times, your Business Rule will be 'After', 'Update' on 'incident' table AND Additional comment changes filter condition
Can you post screenshots of the 2 BRs you have written to understand the issue?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2020 03:03 AM
Hi,
I believe this is related to Incident and incident task.
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2020 03:06 AM
Hi Tahzeeb,
You can use getJournalEntry(1); to pull latest record for update. While for all you can use getJournalEntry(-1); or current.comments.getDisplayValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2020 08:24 PM
Hi Jaspal,
Thanks for the reply.
The Issue I am facing is that I am able to either copy all work notes using getJournalEntry(-1) or Latest using getJournalEntry(1)
But as mentioned I need to copy all the worknotes only during the creation of Task and Later once Task is created Latest worknotes should be copied.
I do I write that condition