Tasks built in related table task_time_worked do not allow any task or time worked to be saved if the related records are added before the main record save


When inserting a record into the Time Worked embedded list prior to submitting the record, a unique key violation occurs and the record cannot be submitted. This error only occurs when the com.snc.time_worked.update_task_timer property is set to True.

The error is:

Unique Key violation detected by database (Duplicate entry 'sys_id' for key 'PRIMARY')
Invalid insert

Steps to Reproduce

  1. Navigate to System Properties > All Properties.
  2. Search for com.snc.time_worked.update_task_timer.
  3. Set Value to true.
  4. Navigate to Incident > Create New.
  5. Right-click on the header and select Personalize > Form layout.
  6. Add Time Worked->Task from Available to Selected.
  7. Click Save.
    The Incident form should open.
  8. In the Time Worked embedded list, click Insert a new row and enter any value.
    Ensure that you have not saved the incident record.
  9. Right click on the header and select Save.
    The unique key violation error occurs and your record is not submitted.


This is expected behaviour when a business rule on the Task Time Worked table is set as a "Before" rule. Changing it to an "After" rule makes the violation disappear. Creating a related record before creating the current one gives this error, in case there is a before business rule on the related record.


Related Problem: PRB590991