Skip to main content

Script evaluation fundamentals

In order to be as efficient as possible, the system only stores the values of fields. This means, that if create a script for Scripted Answer, it will only be evaluated

  • once when it is created
  • and if any of its dependencies (i.e. fields that it uses) changes. Otherwise that data will be stored and, when the checklist is opened again, loaded into that field. (This behavior is true for all "value scripts", which are Scripted answer, data-bound answer, repeat for related/inspected item/elements in list)

All other scripts (like Title, Exists, etc.) will be evaluated every time the checklist is created or opened/loaded.

note

Value handling scripts are the following:

  • scripted answers
  • data-bound answers
  • repeatable areas for inspected or related items or elements in a list

That means, that if you create a Title script that shows the current date, it will display a different date every day you open the checklist: title script with dynamic date So on the 1st of January 2021, it will show "2021-01-01", but if you open it on the February 22nd, it will show "2021-02-22"! Therefore, if you need to display data that does not change, you must store that data in a field within the checklist

For example, in order to change the Title script so that it always displays the date, when the checklist was created, we change the script to use a date field instead of now title script with stored date ...and script the date fields Scripted Answer to now date field with default value scripted That way, the first time the checklist is created, the date field will be set to now. But any subsequent times we open the checklist, this value will just be loaded but not re-evaluated!

When a checklist is saved, the system only stores the values of input fields such as date, text, radio button etc. All additional properties, like is readonly, is hidden, title etc. are not stored at all, but will be evaluated whenever the checklist is loaded. So this splits the types of scripts into

  • value scripts (i.e. scripts that set some field value which will actually be stored)
  • transient scripts (i.e. script which are re-evaluated every time)