Copying worknotes from Incident to Task

Tahzeeb
Giga Expert

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

1 ACCEPTED SOLUTION

Community Alums
Not applicable

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:

find_real_file.png

 

find_real_file.png

 

2. BR on HR Task Table

 

find_real_file.png

 

find_real_file.png

 

 

Expected Results:

HR Task:

find_real_file.png

View solution in original post

31 REPLIES 31

Hi Pooja,

 

I tried similar code but not sure what is wrong, now even if I try to write the similar core for HR Case it doesn't seem to working, below is the screen shot

find_real_file.png

 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

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:

find_real_file.png

 

 

Then I updated the work notes on Incident as "Test 4" and "Test 5"

 

Incident Task:

find_real_file.png

 

 

Incident for your reference:

 

find_real_file.png

Hi shruthiub,

Thank you for the reply

Kindly share the screen shot of Before business Rule Including when to Run and Script

 

Community Alums
Not applicable

1. 1st BR on incident_task

 

 

 

 

 

 

2. 2nd BR on incident table