When a new task record like Incident, Problem, or Change Request, or any record extending task is created with [task_time_worked], if the system property "com.snc.time_worked.update_task_timer" is set to true, a "Unique Key violation detected by database" is thrown.

Steps to Reproduce

1. Set the system property "com.snc.time_worked.update_task_timer" to true.
2. Add "Time Worked > Task" to a change request form.
3. Create a new change request.
4. Add an entry into the embedded list: "Time Worked > Task".
5. Save the change request.


This problem is targeted to be fixed in a future release. To receive notifications when more information becomes available, subscribe to this Known Error article by clicking the Subscribe button at the top right of this form.

As a workaround, edit the Business Rule 'Update task timer' replacing the script with the following:

function updateTaskTimer() {
    var task = current.task.getRefRecord();
    if (!task.isValid())
    //get all time worked for this task
    var tw = new GlideAggregate("task_time_worked");
    tw.addQuery("task", current.task);
    tw.addAggregate("SUM", "time_worked");
    if ( {
        var timeworked = tw.getAggregate("SUM", "time_worked");
        task.setValue("time_worked", timeworked);
        var workflowState = task.isWorkFlow();
        // don't run task workflows or BR: "Task Time Worked" will create more time worked records
        gs.addInfoMessage(gs.getMessage("Time worked entry was modified, updated time in task {0}", task.getDisplayValue()));


Related Problem: PRB1342651

Seen In


Intended Fix Version


Safe Harbor Statement

This "Intended Fix Version" information is meant to outline ServiceNow's general product direction and should not be relied upon in making a purchasing decision. The information provided here is for information purposes only and may not be incorporated into any contract. It is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. The development, release, and timing of any features or functionality described for our products remains at ServiceNow's sole discretion.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2019-07-24 14:08:12