Skip to Content

Assign a Value to a Field of a Workflow Item

Let’s consider the example in which a value is assigned to a field of a workflow item depending on a value of another field of the same workflow item. For example, you might need to show the remaining time until the deadline, when your workflow item is in particular status. The remaining time should be calculated as the difference between the due date and the current server date. And then the calculated value should be assigned to the specified field.

For this example the IF, OR and SUBTRACT functions should be used.

To configure the rule:

1. Select a workspace, select an application.

2. Click «Fields».

3. Create the «Due Date» (ID: Due_Date) field of the Date/Time type.

4. Create the «Remaining Time» field of the Duration type. This field will display the remaining time until the deadline, depending on the status of the workflow item.

Go to the «Field Attributes» of the «Remaining Time» field and select the «Calculated» check box. The «Field Expression» tab becomes available.

5. Obtain the identifiers of required fields and workflow statuses. For example:

  • workflowState — the identifier of the workflow item system field, which represents the current status of the workflow item;
  • wfstate.approvedImplementation, wfstate.ReviewbyManager — the identifiers of the workflow statuses «Implementation» and «Review». You can replace them with identifiers of your custom workflow statuses.

6. Type the following expression into the built-in editor:

IF(

OR($workflowState == ID("wfstate.approvedImplementation"), $workflowState == ID("wfstate.ReviewbyManager")),

SUBTRACT($Due_Date, $$now),

DURATION("PT10M"))

7. Click «Save&Close».

8. Go to «Form» and drag the created fields to the workflow item form. Save the changes.

To check how the created rule works, create a new workflow item and move it through workflow. When the workflow item is in «Implementation» or «Review» status, the «Remaining Time» field will display the difference between the due date and the current server date. Otherwise, the constant value will be assigned to the field (10 minutes in our example) in order to verify the functionality of our expression.