Skip to main content
OutSystems

How to set the values on inputs dynamically

Question

How do I set a default value on an Input that depends on other values?

For example, how do I set a 'To' date to one day after a 'From' date?

Answer

Use the Default Value property to define the default value of a variable or entity attribute.

Use Preparation code to set defaults only when creating a new record.

Use a Change Event if changing one Input should update the value on another Input.

On the example below, the default value of the 'From' attribute is CurrDate(), the current date.

On the example below, the Preparation code:

  1. Checks for a new record;
  2. Sets the value of the 'From' attribute to CurrDate;
  3. Computes the value of the 'To' attribute using the function AddDays.

On the example below, changing the value of the 'From' attribute triggers a Change Event. The flow of the event:

  1. Computes the value of the 'To' attribute using the function AddDays.
  2. Refreshes the Input 'To', because the event executes as an AJAX call.

If the user leaves the Input box empty, the variable is set to the value of the Null Value property.

  • Was this article helpful?