Trying to get a current date into a date field
Hello,
I have an app that has date fields with date pickers. I need to always enter the current date into this field. I cannot find the command to use to write the current date in the field. I tried using the date picker, but that hard codes today's date. Any ideas?
Thanks in Advance
-
Official comment
Hi Carla Buonomo,
- We need to generate the current date using a JS expression.
Example: Execute "return new Date().toLocaleDateString("en-US")" returning $todayDate. - Input the returning variable from the above step into the date field.
Example: Write $todayDate in field input "Date of Birth".
As shown in the screenshot below, this step successfully writes today’s date into the “Date of Birth” field during execution.
Note: According to your required format, you can customise the JS expression used above. A few examples:
-
MM/DD/YYYY →
"return new Date().toLocaleDateString(\"en-US\")" -
DD/MM/YYYY →
"return new Date().toLocaleDateString(\"en-GB\")" -
YYYY-MM-DD →
"return new Date().toISOString().split(\"T\")[0]"
Additional note: If you think this step will be reusable across the project, you can convert the date-generation step into an extension. Click on the step, go to step editor panel, scroll to the JavaScript execution section, and select “Save inline script as new extension.”

- We need to generate the current date using a JS expression.
Please sign in to leave a comment.
Comments
1 comment