This guide will explain how to set the date field one hour ahead.
We will use two Date Time fields and get value from the user in the first field, and the second field will auto-set the value one hour ahead.
Drag and drop two Date Time fields and a JavaScript field. Rename the Date Time fields as shown below.
Click the pencil icon of the JavaScript field and paste the code. Save the changes.
Please use the code below:
// Listen to Formyoula field changes based on Id or label
window.formyoula.form_fields[ 'Start Date' ].on( 'all', function() {
// Increment time for an hour
var one_hour_later = moment( this.get( 'value' ) ).add( 1, 'hours' );
// Set the new field value
window.formyoula.form_fields[ 'End Date' ].set( { value: one_hour_later } );
} );
Try the form. When a user sets the date and time in the āStart Dateā field, the form auto-sets the one-hour later time in the āEnd Dateā field.
Optional: You can hide the second Date Time field labelled āEnd Dateā on the form.
Drag and drop a Field Update Workflow field. Set Field Updates to hide the āEnd Dateā field:
End Date || hidden || true
Save the changes.
Try the form. It will hide the field labelled āEnd Dateā.
For any questions, please contact us - [email protected] or the Formyoula in-app chat š