Skip to content
Verified

Set Data

A saved write, create, update or delete, one record at a time, with events to validate and react around it.

A Set Data program is a saved write. Creating a new row, updating an existing one, or deleting it, every mutation in a Xuda app is a Set Data program: a target datasource, an operation mode, parameters mapped onto the table's fields, and lifecycle events for validation or side effects.

Properties

progDataSource

Same shape as Datasource. For C the filter fields are unused, the write always creates a new row. For U and D, dataSourceFilterModelType plus dataSourceIndexId (or a query) locate the target record.

progFields

Each entry binds a parameter to a column on the target table (data.type: "table") or declares a caller-only parameter (virtual). When a workflow calls the program, matching parameters populate these fields before the write runs.

progEvents

Calling a Set Data program

The set_data action runs it; name.outputField can receive the written record on the caller:

json
{
  "id": "1", "data": {
    "action": "set_data",
    "name": { "prog": "97a_std_…", "properties": {}, "parameters": { "class_id": { "fx": "@glb_class_id" } }, "outputField": "GLB_Grades" },
    "enabled": true
  }, "props": {}
}

Worked example

Choose the mode

crudMode: "C" to insert, "U" to update a located row, "D" to delete one.

Bind the fields you write

Give each progFields entry data.type: "table" with a field_id matching the target table's column.

Locate the row for U or D

Set dataSourceFilterModelType to index (with dataSourceIndexId) or query, exactly as a Get Data program would.

Create a Set Data node under Programs, choose the CRUD mode on its Properties tab, then bind fields on the Fields grid the same way as Get Data.

xml
<meta lang="json5">
{
  id: "delete_student_profile",
  menuTitle: "Delete Student Profile",
  crudMode: "D"
}
</meta>

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

<datasource lang="json5">
{
  type: "table",
  table: "student_profiles_table",
  filter: {
    mode: "query",
    query: { student_id: "@student_id_in" }
  }
}
</datasource>
json
{
  "properties": { "menuType": "set_data", "menuName": "Create Student", "crudMode": "C", "allowCreate": false, "runAt": "" },
  "progDataSource": { "dataSourceType": "table", "dataSourceTableId": "5b1_tbl_a953848a71c5" },
  "progFields": [
    { "id": "b2c3d4e5-…", "data": { "field_id": "STU_Student_Id", "type": "table" }, "props": { "fieldType": "string" } },
    { "id": "c3d4e5f6-…", "data": { "field_id": "STU_Full_Name", "type": "table" }, "props": { "fieldType": "string" } }
  ]
}