Skip to main content
Skip table of contents

Form scripts

It is possible to write small scripts that update the form values. The script is run whenever you change a field in the form whilst completing the form. This is a functionality that has to be enabled by Microbizz, and currently it only works when completing a question form in the browser, not in the app.

When you setup the form you can specify if a field should be updateable from the script:

Editing the script

The script is edited in the SCRIPT tab, where you can also try out the form:

When the script is run a variable named a is set up to hold all the current values from the question form.

You may update the variable, and the question form will then ne updated with the new values. To update the field with ID 5 you write a new value to a[5]. You access the current values the same way: a[3] will return the current value of the field with ID 3. You can see the ID of a field by holding the mouse over the field, the ID will appear in the tooltip.

Field types

You can update most field types, except for files, pictures and signatures, but including the static text fields.

Notice that when you set the value for a radio / multi / one-of-many field, you should not specify the text that is displayed to the user, but instead specify the underlying value used by Microbizz. F.ex. for the field below you might specify

a[7] = 2

instead of

a[7] = "Ringo"

For multi fields you have to specify a list of values to select, eg.: a[8] = [2,5,1] .

Feedback

The script may report back to the user by using the function echo().

F.ex.:

echo("Remember to inform the accounting department")

This text will be shown to the user just like many other informations:

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.