Skip to main content

Trying to get a current date into a date field

Comments

1 comment

  • Official comment
    Venkata Sai Kumar G

    Hi Carla Buonomo,

    1. We need to generate the current date using a JS expression.
      Example: Execute "return new Date().toLocaleDateString("en-US")" returning $todayDate.
    2. 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.”
     

Please sign in to leave a comment.