Automatically Setting Date and Datetime Values

This is the third installment in the “Automatically Changing Data During a Workflow” series.

In the previous articles, we covered String (Title) and Numeric (total amount) types. This time, we’ll show you how to automatically set Date and Datetime Data Items using the Update Data step.


Use Cases

  • Automatically set a “Retention Expiry Date” to 30 days after the received date
  • Automatically set a “Billing Date” to the first day of the month following the application date
  • Calculate and set a “Contract Renewal Date” to one year after the contract start date

Calculating a new date based on an existing date and setting it automatically is a pattern well suited for the Update Data step. Asking people to calculate dates manually is prone to mistakes and omissions. By automating this, you can ensure accurate and reliable records.


How to Configure

Place a Update Data step and open its settings screen. Select a Date (or Datetime) Data Item as the “Data Item to be set value,” and enter an expression in the “Value or Expression” field.

Update Data step settings screen

Calculating Based on Another Data Item’s Date (Date Type)

Example: Setting the “Retention Expiry Date” to 30 days after the Date-type Data Item q_ReceivedDate (Received Date):

#q_ReceivedDate?.addDays(30)

Setting the first day of the following month:

#q_ApplyDate?.addMonths(1)?.getFirstDateInMonth()

Setting one year (12 months) later:

#q_ContractStartDate?.addMonths(12)

Setting the Date/Datetime When the Step Is Processed

The date when the step was processed (Date type):

#today

The datetime when the step was processed (Datetime type):

#now

#today and #now set the date or datetime of the moment this step is executed, regardless of any Data Item. Note that if the Case has been stalled midway, the date may differ from the Case Start Date.


Verifying the Result

Once the configuration is complete, start a test Case and let it pass through the step.

Case detail screen

If the target Date Data Item contains the expected value on the Case detail screen, the configuration is successful.


Difference from “Setting Deadlines”

Setting Deadlines explains how to specify a Timer Event’s deadline directly using an expression.

What this article covers is a different topic. It explains how to update the value of a Date or Datetime Data Item managed within the workflow using the Update Data step. This is useful when you need to store a date in a Data Item for reference in subsequent steps or for aggregation and analysis.


Summary

What You Want to DoExample Expression
Set N days after another Date Data Item#q_ReceivedDate?.addDays(30)
Set the first day of the month following another Date Data Item#q_ApplyDate?.addMonths(1)?.getFirstDateInMonth()
Set N months after another Date Data Item#q_ContractStartDate?.addMonths(12)
Set the date when the step was processed#today
Set the datetime when the step was processed#now

For details on the methods available in expressions, see R2271 and R2276.

Discover more from Questetra Support

Subscribe now to keep reading and get access to the full archive.

Continue reading