The document form of the customer app from the series Building a customer app in Uniface 10 edits quotes, orders and invoices. In the first click test, creating a quote worked - the service returned a document ID and the message said "Document 1 created." But the header line of the form read:
(no number yet), , customer #, date
Type, status, customer and date were all empty. The lines below were fine. This article is about why, and about a small rule that makes this kind of bug easy to spot.
Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) and SQLite 3.50.2 via the SLE driver, October 2026.
How sql/data returns rows
sql/data runs a query and puts the result into $result as a Uniface list:
- each row is one item of the outer list, separated by the GOLD
;, - each row is itself a list of columns.
So a typical list reader looks like this:
forlist vRow in vData
getitem vId, vRow, 1
getitem vNo, vRow, 2
...
endfor
and code that wants the first row of a result writes getitem vRow, vData, 1 and then reads the columns from vRow.
Two services, two contracts
The service for the document list returns the raw result:
sql/data vSql, "CUSTOMERS"
...
pData = $result
pCount = $itemcount(pData)
The service for a single document does something slightly different at the end:
vData = $result
if (vData = "")
pError = "The document %%(pDocId) does not exist."
return -1
endif
getitem pData, vData, 1
return 0
It already takes the first row and returns the row itself. That is a sensible contract for a "get one" operation - but it is a different shape from the list operations.
The form treated both the same way:
activate "SALESDOC_SVC".GET_DOC(pDocId, vData, vError)
...
getitem vRow, vData, 1
getitem vType, vRow, 2
getitem vRow, vData, 1 on a row returns its first column - the document ID. Reading column 2, 3, 4 from a single value returns empty strings. No error, no warning: just empty fields.
The fix
One line in the form:
vRow = vData
getitem vType, vRow, 2
getitem vNo, vRow, 3
getitem vCust, vRow, 4
After recompiling, the header showed what it should:
QUOTE Q-2026-00001, DRAFT, customer #15, date 2026-10-17, valid until 2026-11-16
Why this was easy to miss
The app is not consistent here. The product service's GET_PRODUCT also returns a single row, but the subscription service's GET_SUB returns the raw $result, a list with one row. The document service has eleven operations; four of them return lists of rows, and the form was written from the pattern of the list readers.
A second detail: the bug did not break anything that a quick look would catch. Creating the quote worked, the lines and totals were right. Only the header was wrong.
A naming rule that would have helped
For the remaining forms of this stage, every service call was checked against a simple convention:
-
pDatafrom aLIST_...operation is read withforlist vRow in vData. -
pDatafrom aGET_...operation: look at the service first. If it ends withgetitem pData, vData, 1, assignvRow = vData; if it ends withpData = $result, usegetitem vRow, vData, 1.
The name alone does not tell you the shape - in this app, two GET_... operations return different shapes. Then test with a record that has a value in every column. Empty strings in a form are easy to overlook; an empty status next to a status that you know is DRAFT is not.
Top comments (0)