Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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,

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

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

Community Alums
Not applicable

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?

Jaspal Singh
Mega Patron
Mega Patron

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();

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