Skip to main content
Add days to a date selected by user

This is an AppBuilder Sample Script.

Updated over a month ago

Suppose there are two 'Datepicker' fields with the field name 'Start_Date' and 'Due_Date' respectively. The due date should display automatically once the start date is entered by adding 4 days to it. In such a case, you can use the drag and drop code editor to define a condition like below upon the 'onChange' event of 'Start_Date' control:

Here are the steps to understand how you can define such a condition:

1. From the left panel, click on the option 'Custom Functions'. Select the fifth block called 'Set Value' and drag it to center of the editor.

2. In the 'Control Name', select 'Due_Date'.


3. From the left panel, click on the option 'Custom Functions', Select the block for 'Add / Subtract Days' and replace block for 'Value' field with this block.

4. Select the 'Start_Date' control name in 'Date' field for 'Add / Subtract Days' block and set 'No of days' to '4' instead of the default value '0'.

5. Once done, click 'OK' (at bottom right) to save the changes and exit the code editor, then save / publish the form design as needed. Once the form design is published and executed, the changes will be applicable for the new forms created under the related form type.



Did this answer your question?