6.3 Unable to Overwrite the Calculated Value on Date/Time Component

Issue: On Date/Time component, when you define a JavaScript code using moment() function to calculate the date and time based on user input in the Number component, the value is calculated as expected. However, if you select the Allow the calculated value to be overridden manually check box, you will not be able to change the calculated value in form preview mode. This issue occurs because the time is updated continuously on the Date/Time component, which does not allow the calculated value to be overwritten manually.

Workaround: You can resolve this issue by using the startOf('day') or endOf('day') function in the code to ensure that the set time does not change when the value is calculated on the Date/Time component. Perform the following actions:

  1. From the Basic Components, drag and drop the Number component into the workspace, then provide a label in the Label field and click Save.

  2. From the Advanced components, drag and drop the Date/Time component into the workspace.

  3. (Conditional) To set the time to 12:00 AM (start of day), click the Data tab and provide the following JavaScript code in the Calculated Value field:

    value = moment().startOf('day').add(data.number, 'days')
  4. (Conditional) To set the time to 11:59 PM (end of day), click the Data tab and provide the following JavaScript code in the Calculated Value field:

    value = moment().endOf('day').add(data.number, 'days')
  5. Select the Allow the calculated value to be overridden manually check box.

  6. Click Save.