- 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-09-2020 02:38 AM
I would try to write after business rule-insert,update. Example- if i need to copy work notes from sc_req_item to sc_task-
function onAfter(current,previous)
{
current.work_notes=current.request_item.work_notes;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2020 08:25 PM
Hi Swapnil
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.
How do I write that condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2020 09:14 PM
Hi Tahzeeb,
So I assume you must be having business rule on incident table after insert and update
1) when incident is inserted -> copy all work notes to task
2) when incident is updated -> only copy latest work notes
getJournalEntry(-1) -> this gives all work notes
getJournalEntry(1) -> this gives latest work notes
What issue you are facing?
Regards
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:10 AM
Hi Ankur,
The Issue is how do I specify the condition which that this is Task creation so all the work notes should be copied
And once Task is created only Latest work notes should be copied.
Writing below script only copies Latest worknotes
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',current.parent.sys_id);
gr.query();
while(gr.next())
{
gr.work_notes=current.work_notes.getJournalEntry(1);
gr.update();
}