HR Case takes a long time to generate tasks if the HR task uses HR Task template of type 'Checklist'


Description

When generating multiple HR Tasks that use HR Task Template of type "checklist" via HR Service is resulting in slow performance

Steps to Reproduce

1. Hop into any instance and create a new HR service with "service activity" as fulfillment type (or modify any existing HR service)
2. Navigate to HR Administration-> Manage HR Task Templates
3. Create a new HR Task Template of type 'Checklist' and add a couple of items to it
4. Create multiple(for example, 9) Service activities: (Note: Order on all service activities should be 1)
Activity Type: Task
Child task template: Here select the HR task template created in step 3
5. Create an HR case using the HR service that we created/modified in step 1
6. Move the HR case state to ‘Ready’
7. Observe the HR Tasks gets generated but there is a significant delay of around 20 seconds

Workaround

The workaround for this issue could be applicable when:

1. The HR Service of the case has Fulfillment Type as Service Activity.
2. There are multiple Service Activities of Activity Type -  Task with order 1 with above service.
3. And many of those service activities have Child task template, setting HR Task Type as Checklist with multiple checklist items. 

While moving a case with above specs may take about some considerable time while moving from Draft to Ready state.
This is happening since there are couple of BRs on checklist items tables which adds multiple checklist items to HR Task's work notes. Now updating a worknote on HR Task triggers another BR to set worknotes on the parent case.

There is no easy way to get around this slowness without impacting the functionality. One way could be to call setWorkflow false on the BRs on checklist item which will get the performance better but worknotes won't be added to the HR Case.


Related Problem: PRB1406641