- 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 04:32 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2020 08:34 PM
Hi,
Did you try script shared by me earlier? sharing once again
Also parent is the field on incident_task table which stores incident
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 07:40 AM
Hi Tahzeeb,
I have tried this on my PDI and it works. Can you try-
1. Create a 'Before' 'Insert' BR on 'incident_task' table and add the script:
current.work_notes = current.incident.work_notes.getJournalEntry(-1);
2. Create an 'After' 'Update' BR on 'incident' table with filter condition 'Work Notes changes' and add the script:
var incTask = new GlideRecord('incident_task');
incTask.addQuery('incident', current.sys_id);
incTask.query();
while(incTask.next()){
incTask.work_notes = current.work_notes.getJournalEntry(1);
incTask.update();
}
Test Scenarios:
When I created incident I added the work notes "Test 1, Test 2, Test 3" and then I created an incidnet task:
Incident Task:
Then I updated the work notes on Incident as "Test 4" and "Test 5"
Incident Task:
Incident for your reference:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2020 08:34 AM
Hi shruthiub,
Thank you for the reply
Kindly share the screen shot of Before business Rule Including when to Run and Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2020 08:45 AM