Setting a dynamic value as an initial answer for a question is possible by setting it's expression. Previously, only static values could be set for questions other than a calculated question. Below, you'll find an example to help you get started building expressions for initial answers. 

If you'd like access to this feature, please contact support@devicemagic.com.  
Please note, this feature is not fully supported on Android yet.


First, open your form in the designer and locate the question you'd like to set the initial answer for. Click the question and check the "Show Advanced Settings" option.

You'll see the Initial Answer text box for static values and the option to set an expression just below.

Click "set expression".

If you're unfamiliar with our available functions and other calculated question capabilities, have a look at this article before reading further.

To set the initial answer to the current date present on the device, use the expression pictured below.

See the article link above for information on how this expression is constructed. When the form is opened in the app, it'll look like this:

To change the initial answer, click the "x" to the right of the answer.

Note: Your initial answer expression must return a value in the format required by the field type. For example, if you are using a LOOKUP to fetch a Date, Time, or Date-Time value, the data must be formatted correctly in your spreadsheet:

Date should be formatted as follows: yyyy-mm-dd
Example: 2019-10-30

Time should be formatted as follows: hh-mm-ss Example: 15:06:00

Date-Time should be formatted as follows: yyyy-mm-ddThh:mm:ss  
Example: 2019-10-30T15:06:00


Useful Examples:

Duplicating Answers in a Repeat Group

Note, this is supported on iOS only at this time. 

When using a Repeat Group, there may be instances where you’d like the initial answer to populate with the answer from the previous entry in the group. This is useful if you are collecting information about multiple items that all share the same (or very similar) details. This can be accomplished by using the following initial answer expression format:

.Your_Repeat_Group[COUNT(.Your_Repeat_Group) - 2]/Some_Question 

For example, if you had a Repeat Group called “Buildings” and fields within the Repeat Group called “Building Name”, “Year Built”, and “Square Feet”, your form builder would look like this:

In this example, you would set the Initial Answer Expression on “Building Name” as follows: 

Use the same initial answer expression for each of the following questions within the repeat group, updating only the field name. So the initial answer expression on the field "Year Built" would look like this:

 .Buildings[COUNT(.Buildings) - 2]/Year_Built 


Now, once the user completes an entry in the repeat group, all the data will carry over into the following entry as the initial answers. 

Watch this space for future examples.

If you have any questions or comments feel free to send us a message at support@devicemagic.com.

Did this answer your question?