Before reading this section, we suggest you take a look at getting started with formulas first. In general, it is useful to do the guided tour before you start with the other guides.

Actions are a different type of formula. You can add them in almost the same way, via Actions > Action.

adding a new action
adding a new action

The one big difference between formulas and actions is that actions do not return a value. For example, consider the formula now(). The function now() gives the user the current date, or, it returns the current date. An action is different: it does something, and that’s it.

The easiest example is the initvar() action. This action sets the initial value to a variable, but when the user edits it, the initial value is discarded. You can do the same with questions by entering something in the default-field. An initvar() might look like this:

initvar(^name, 'John')
initvar(^gender, 'Female')

As you might notice, we do not have to do anything else to make this work. The initvar() expression will initiate a value for the question and that’s that.

Another example would be the action setproperty(). This versatile action can assign all kinds of properties to questions, yet it never returns any value. Consider this example:

setproperty(^name, maxlength, 10)

This will change the maximum length of the user’s answer to the question name to 10. Yet it does not return any value! You can use this for several different goals, such as setting readonly and not null properties to questions. You can also edit the precision of numbers, and more.