Data API: Grid lines and grid forms
Many Xpoda forms have a grid. The Data API handles the two kinds of grid differently:
| Form | In the API |
|---|---|
| A form with a header and a grid of lines (an order and its order lines) | A record has a lines array. Header and lines are read and written together, in one request. |
| A form whose grid is the master record (Grid Master: every grid row is a record of its own) | Every row is a record. The grid's columns are ordinary fields; there is no lines. |
GET /forms/{form}/schema shows which one a form is: a form with lines has a lines property.
Forms with lines
Reading lines
GET /forms/{form}/records/{id} always returns the lines, in the order of the grid:
{
"id": 15,
"OrderNo": "SO-2026-0015",
"Customer": "Demka",
"lines": [
{ "id": 101, "ItemCode": "B-200", "Quantity": 10, "UnitPrice": 120.5 },
{ "id": 102, "ItemCode": "N-080", "Quantity": 25, "UnitPrice": 4.2 }
],
"_meta": { ... }
}
- A line's
idis its own number, used to change it later. - Line field names are the grid's column names; their types are in the schema under
lines. - In a list, add
expand=linesto get each record's lines:GET /forms/sales-orders/records?expand=lines. Without it, lists do not include lines.
Writing lines
Send lines in the same body as the header. lines is always the complete set of lines for the record:
In the lines array | Result |
|---|---|
A line with an id | That line is changed. Only the fields you send change; the others keep their values. |
A line without an id | A new line is added. |
| An existing line that is not in the array | That line is deleted. |
The order of the array becomes the order of the lines.
Create an order with two lines:
POST /forms/sales-orders/records
Content-Type: application/json
{
"OrderNo": "SO-2026-0016",
"Customer": "Demka",
"lines": [
{ "ItemCode": "B-200", "Quantity": 10, "UnitPrice": 120.5 },
{ "ItemCode": "N-080", "Quantity": 25, "UnitPrice": 4.2 }
]
}
Change the quantity of line 101, keep line 102, add a new line (and so delete any other line):
PATCH /forms/sales-orders/records/15
Content-Type: application/json
If-Match: W/"639286201041600000"
{
"lines": [
{ "id": 101, "Quantity": 12 },
{ "id": 102 },
{ "ItemCode": "W-010", "Quantity": 100, "UnitPrice": 0.35 }
]
}
Leaving a line out deletes it, so send { "id": 102 } for every line you want to keep unchanged.
When lines are left out
| Request | Without lines in the body |
|---|---|
POST | The record is created without lines. |
PATCH | The lines stay as they are. Change header fields without touching the lines. |
PUT | All lines are deleted (PUT replaces the whole record). |
To delete all lines with PATCH, send "lines": [].
Rules for lines
- A line
idmust belong to the record in the URL; otherwise the request is refused with422 validation_failed(Line 205 does not belong to this record). - A new line must have at least one value.
- Grid columns marked cannot be empty in Studio are required: a new or changed line without a value for them is refused (
lines[1].Quantity: Required.). - Errors point to the line by its position in the array:
lines[0]is the first line. - If the form has the rule that it cannot be saved without lines, a record without lines is refused with
422 save_rejectedand the rule's message. - If the API user may see the grid but not change it, the lines are returned but
linesin a write is refused. If the API user may not see the grid, lines are neither returned nor changed; saving the record keeps them. - A grid column's record filter can skip a line when it is saved, as on the form screen. The response shows the lines that were really saved.
- Header and lines are saved in one transaction: if a line is refused, nothing is saved.
- Updating a line also updates the record, so the record gets a new ETag.
Grid Master forms
In a form whose grid is the master record, each row of the grid is a record in the form's table. In the API:
- every row is a record with its own
id, read and written through/forms/{form}/recordslike any other form; - the grid's columns are fields of the record, next to the form's own fields;
- there is no
linesproperty.
POST /forms/price-list/records
Content-Type: application/json
{ "ItemCode": "B-200", "ListPrice": 129.9, "ValidFrom": "2026-11-01" }
Creating, changing and deleting work as described in Data API: Writing records, with two differences:
- After save actions run when a row is created, but not when it is changed through the API. The form screen saves Grid Master rows differently from other forms; the API changes a row directly so it can report the result reliably.
- Deleting a row removes only that row, as the form screen does.
Record Control rules, required grid columns and If-Match apply as for other forms.