Overview
The Date Picker Form Element allows users to select dates using a calendar interface. Automatically setting default dates can significantly improve workflow efficiency and user experience in many business scenarios. This article explains how to set the current date programmatically using the Calculate Date activity, the form load event and the Set Form Element Property activity.
Business Value
Pre-setting dates in workflows addresses several common business needs:
- Streamlined Data Entry: Reduces manual clicks when the current date is the most common choice
- Error Prevention: Minimizes date entry errors by providing accurate default values
- Consistent Timestamps: Ensures standardized date formats for record-keeping
-
Time Efficiency: Particularly valuable for:
- Field workers logging multiple reports in a day
- Inspection forms that primarily use the current date
- Maintenance records that default to today's date
- Permit applications where the submission date is automatic
Configuration
Setting a specific date requires three steps:
- Getting the current date
- Add a load event to the form element
- Configuring the load event to use a Set Form Element Property
In this example, we are going to set a Date Picker to today's date. This same approach could be tweaked to target a specific date by further configuring the Calculate Date activity.
Step-by-step
- Add a Calculate Date activity
- Set Date input parameter to:
today
- This method outputs the date in Unix timestamp format (e.g., 1739433600000) with time set to midnight (00:00:00) from the .value output.
- Note that, using the Offset amount and Offset units, this could be altered to calculate a specific date in relation to the current date
- Set Date input parameter to:
- Within the Form, on the Date Picker form element, add a Load Event
- Within the Load Event, configure a Set Form Element Property Activity with the following arguments:
- Property Name:
value
- Property Value:
=$date1.value
- Note we do not need to set the Element property - because we will by default target the parent form element (e.g. the Date Picker)
- Property Name:
Testing and Examples
Workflow Sandbox Testing
You can use the Workflow Sandbox to test your date picker configuration:
- Open your workflow in Workflow Designer
- Click the "Run" button to launch the Workflow Sandbox
- Test the form load behavior and verify the correct default date appears
- Test any offset calculations if configured
Reference Implementation
- An example workflow demonstrating this configuration is available here:
- portal item / designer
- Attached below
Additional Notes
- The Calculate Date Activity's Offset feature enables you to set dates relative to today (e.g., tomorrow, next week, previous month)
- Always test the date calculation with different time zones if your application serves users across multiple regions
- Consider adding validation or user messaging if the calculated date falls outside acceptable ranges for your business process
Comments
0 comments
Please sign in to leave a comment.