Run JavaScript on a block to set a variable, flag a respondent or prepare a value from earlier answers.
Scripts are how you compute something the interview can’t express with conditions alone: set a variable from a combination of earlier answers, flag a respondent who matches a profile you care about, prepare a value that a later question or a webhook will use. You write a few lines of JavaScript on a single block, and they run for every respondent who passes through it.The Script button sits in the question panel of the block. The modal that opens says what it does: “Run JavaScript when a node opens or after a respondent submits an answer”.
The answer given to a question, addressed by its question code. This is why the question code is worth setting deliberately: it’s the handle your scripts use.
The full API reference isn’t published yet. Stick to questions.<CODE>.responseValue for reading and vars.<name> for writing — those are the two documented entry points.
Quick run executes the script in an isolated state, without saving anything. It’s the way to check that your code does what you think before any respondent goes through the block. Nothing you run this way touches the collected data or the variables of a real session.
Set the question codes before you write the script. Renaming a code later breaks every script that referred to the old one, silently.