Skip to content
Verified

Batch

One callable program that orchestrates several steps, a multi-part procedure with one id to call it by.

A Batch program orchestrates several steps as one callable operation. Anywhere a procedure would otherwise be copy-pasted across Components, a multi-step save, a loop over records, a sequence of API calls, a Batch gives it one name and one id. From a caller's side it looks exactly like a Get Data or Set Data program: call it with the batch action, pass parameters, get a result back.

Properties

progFields

Batch parameters follow the common shape (data.field_id, data.type: "virtual", props.fieldType), referenced inside the Batch's workflow as @field_id.

progEvents and the workflow body

Unlike a Table or an Alert, a Batch's actual logic is not a top-level array, it lives inside progEvents, almost always the on_load event, whose workflow array is the Batch's body:

A step inside that workflow can be any action in the Workflow catalog: get_data, set_data, call_native_javascript, call_project_api, call_external_api, delay, update, raise_event, a nested batch call, and more. Each step can carry props.condition to gate it, or props.async: true to fire it without waiting.

Calling a Batch

json
{
  "id": "1", "data": {
    "action": "batch",
    "name": { "prog": "5b1_bth_…", "properties": {}, "parameters": { "class_id": { "fx": "@glb_class_id" } } },
    "enabled": true
  }, "props": {}
}

Worked example

Declare the parameters

progParams for whatever the Batch needs from its caller, mirrored into progFields.

Build the body on on_load

Add steps to the on_load event's workflow: a get_data to read, a computation, a set_data to write back.

Call it like any other program

batch action, name.prog set to this Batch's id, results reachable through the caller's own fields.

Create a Batch node under Programs, declare parameters on its Properties tab, then build the step sequence on the Events → on_load → Workflow editor, the same workflow editor every other program uses.

xml
<meta lang="json5">
{
  id: "rebuild_class_roster",
  menuTitle: "Batch Print Student Packets"
}
</meta>

<params lang="json5">
{
  in: { campus_in: "string" }
}
</params>

<datasource lang="json5">
{
  type: "table",
  table: "student_profiles_table",
  filter: {
    mode: "index",
    activeIndex: "campus_idx",
    indexes: { campus_idx: { campus: { from: "@campus_in", to: "@campus_in" } } }
  },
  limit: 50
}
</datasource>

<events lang="json5">
{
  before_record: [
    { action: "delay", name: { value: "1" } }
  ],
  after_record: [
    { action: "debug", name: { value: "Prepared one student packet for printing" } }
  ]
}
</events>

A Batch bound directly to a datasource runs its before_record / after_record steps once per matching row, the iterative form of the unit.

json
{
  "properties": { "menuType": "batch", "menuName": "Rebuild Class Grades", "runAt": "server", "progParams": [] },
  "progFields": [
    { "id": "b2c3d4e5-…", "data": { "field_id": "class_id", "type": "virtual" }, "props": { "fieldType": "string" } }
  ],
  "progEvents": [
    {
      "id": "d4e5f6a7-…", "data": { "type": "on_load", "parameters": [], "condition": "" },
      "workflow": [
        { "id": "step-1", "data": { "action": "get_data", "name": { "prog": "97a_gtd_…", "parameters": { "class_id": { "fx": "@class_id" } } }, "enabled": true }, "props": {} },
        { "id": "step-2", "data": { "action": "set_data", "name": { "prog": "97a_std_…", "parameters": { "class_id": { "fx": "@class_id" } }, "outputField": "GLB_Grades" }, "enabled": true }, "props": {} }
      ]
    }
  ]
}