Plain JavaScript, run via flutter_js. Decides which layout partials actually get included when a PDF is generated, and can prepare presentation data for blocks to use. Optional - a project with nothing conditional doesn't need it. Edited via the Script Editor. Runs after validate.js passes - see the full processing pipeline.

APIs available

Name Type Meaning
inputs object Same submitted-data map validate.js sees. Assigning a new property onto it forwards that value to every block (see below); reassigning an existing submitted field's value has no effect.
overlay(filename) function Queues a layout partial (path relative to the project root) to be merged into this generation run.
overlay("overlay.json");             // always include the base layout

if (inputs["is_certified"]) {
  overlay("certified_badge.json");   // only when the checkbox is on
}

Handing computed data to blocks

Compute presentation data here instead of writing a long formula inline in a block's own JSON, by assigning it as a new property on inputs:

inputs.gridData = [];
for (var i = 0; i < inputs.options.length; i++) {
  var option = inputs.options[i];
  inputs.gridData.push(
    { text: (i + 1) + '. ' + option.description },
    { text: '$' + option.price, 'text-align': 'right' }
  );
}

overlay("overlay.json");

(Turning a repeating group into grid cells specifically has its own walkthrough: Generating Grid Data.)

A block then references it directly:

{ "id": "options_grid", "type": "grid", "columns": 2, "data": "inputs.gridData" }

Two behaviors worth knowing: