Form scripts
Reading, editing and testing the scripts a form still runs.
Most of what a form does, Kestral does natively: conditions, functions, data sources and workflows. A form imported from Falcon can still carry a few pieces of JavaScript that Kestral runs in a sandbox. Advanced โ Scripts in the form designer lists every one of them, so none of them is hidden from you.
What you see
Open a form (or a form part) in the designer and choose Advanced, then Scripts. The list has three groups:
- Page script: statements that run when the form is saved or submitted.
- Component scripts: a script on one question. Its trigger decides when it runs, and each action sets the question's value.
- SetValue rules: rules from the firm's Falcon rules, compiled into a trigger and an action.
Each script shows:
- where it came from: From Falcon, Edited in Kestral ยท from Falcon, or Authored in Kestral;
- the fields it reads and writes;
- the firm's original text, beside it.
Editing
Type into the script. After data., data[", row. or row[", Kestral suggests the form's own field names. Problems are underlined as you type:
- a syntax error. Scripts run as ES5 JavaScript, so arrow functions and
letare not available; - something the sandbox does not provide, such as
$,jQueryorwindowin a component script; - a field name the form does not have. This is a warning, not a block: a part's script may read a field its host supplies.
Save script keeps your edit on the draft. It becomes yours, and the firm's original stays beside it. Put back the firm's original and save to undo the edit. Publish as usual when you are ready.
A script that is being replaced by a native construct cannot be edited.
Trying it on real answers
Run against a saved submission runs the script, as you have it now, over the answers of a submission this form (or a form using this part) already has. It shows each field the script would change, before and after, and what it read. The submission itself is never changed.