Configuring a calculated time value customization

You can configure a calculated time value to indicate the age of work items.

Before you begin

Confirm that the process attachment scripts configuration is enabled on your server. You must be a member of the JazzAdmins repository group to modify server properties.
  1. Point your browser to the following URL: https://JazzTeamServerName:9443/ccm/admin
  2. On the Application Administration page, click the Advanced Properties tab and scroll to the Work Item Component section.
  3. Set the Enable Process Attachment Scripts property to true.
  4. At the top of the page, click Save.

About this task

This task calculates the age of a work item. The task uses a JavaScript script to retrieve the creation date and the built-in attributes for the current time to compute the age of the work item.


Create an instance of an attribute customization.

  1. Open the Attribute Customization page.
    1. In the Work Items perspective, in the Team Artifacts view, right-click the project area and click Open.
    2. Click the Process Configuration tab.
    3. Expand Project Configuration > Configuration Data > Work Items, and then click Attribute Customization.
  2. In the Attribute Customization aspect editor, add a new calculated value definition. Select Calculated Values, and then click Add.
  3. In the Add Configuration dialog box, complete the fields.
    1. In the Name field, enter a name for the script.
    2. In the Type field, select Calculated Values.
    3. In the Provider field, select Script Based Calculated Value.

      Add Configuration dialog

    4. Click OK. The new customization is displayed in the types section under Calculated Values.

      Attribute Customization dialog with Age Calculation calculated value script defined

  4. If you previously created a script function that subtracts the current time from the creation date and returns a value, load the script. In the Configuration section, next to the Local File Path field, click Browse to find and load the script. Alternatively, you can click Fill in example to download a sample script that you can customize.
    The following sample is a JavaScript function that subtracts the current time from the creation date (in milliseconds) and returns the value.
    // The script name must be the same in lines 1 and 8.
    (function() {
    var WorkItemAttributes =;
    var fromISOString =;
      dojo.declare("org.example.calculated.AgeValueProvider", null, {
        getValue: function(attribute, workItem, configuration) {
          var creationDate = fromISOString(workItem.getValue(WorkItemAttributes.CREATION_DATE));
          if (creationDate) {
            var ageInSeconds = ( - creationDate.getTime()) / 1000;
            var days         = parseInt(ageInSeconds / 86400);
            var hours        = parseInt((ageInSeconds-days * 86400) / 3600);
            var minutes      = parseInt((ageInSeconds-days * 86400 - hours * 3600) / 60);
            return days + " d, " +  hours + " hr, " + minutes  + " min";
          return "";

Associate the new customization with an attribute.

  1. Expand Project Configuration > Configuration Data > Work Items, and then click Types and Attributes.
  2. In the Types and Attributes aspect editor, select the work item type, such as Defect or Task, that contains the attribute to customize.
  3. Scroll to the Attributes section. Select the attribute to customize, and then click Edit.
    Alternatively, click Add to add a custom attribute to apply the customization to, select it, and then click Edit.
  4. In the Edit Attribute or Add Custom Attribute dialog box, in the Calculated Value field, select the new customization that you created.

    Add Custom Attribute dialog box

  5. Scripts that are associated with an attribute customization for a calculated value run only when a dependent attribute changes. Because you want to track the age of the work item, edit the new attribute that you applied the customization to.
    1. Next to the Dependencies field, click the Add button Add button and select the Modified Date attribute.

      Edit Custom Attribute dialog with a dependency defined.

    2. Click OK.
      In the Types and Attributes aspect editor, in the Attributes section, the dependency for the attribute is displayed. Attributes section where the dependency is displayed

Add the new attribute to the Editor Presentation.

  1. Expand Project Configuration > Configuration Data > Work Items, and then click Editor Presentations.
  2. In the Editor Presentations aspect editor, in the Editor Presentations section, select the tab section to display the new attribute on and click Add Presentation.
  3. In the Add Presentation dialog box, complete the fields.
    1. Select Attribute-based Presentation.
    2. In the Attribute field, select the custom attribute that you defined in step 8.
    3. In the Kind field, select a definition for the presentation.
    4. In the Read-only field, select true to configure the new calculated value field to be read-only.

      Add Presentation dialog box

    5. Click OK.
  4. To save your changes to the project area, at the top of the Project Area Configuration page, click OK.


After you save your project area configuration, all new work items of this type will contain the new attribute. The calculated time value script runs and the new attribute is updated in the new work items in following instances:
  • Each time the new work items are saved
  • Each time the dependent attributes that are associated with the new attribute are updated