Order entry forms need lines: article, quantity, price, net. In an earlier version of a Uniface 10 customer app the lines lived in a text field fed from item lists. That works, but nobody can correct line 3 directly. This article shows the version with a real row list: a non-database entity shown as a grid, with triggers per row and nothing written to the database until the user saves.
Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, SQLite 3.50.2 via the SLE driver, November 2026.
The grid entity
The form has three non-database entities: a header (supplier, note, delivery date), the lines, and a footer (total, buttons). The IDE palette calls the line entity "Non-DBMS Entity: Grid". In an XML export it is a normal entity of the form with one extra property:
<DAT name="ULABEL">QPO_LIN</DAT>
<DAT name="UBASE">NOMODEL</DAT>
<DAT name="UFORM">QPO_FRM</DAT>
<DAT name="UKVERSION">7</DAT>
<DAT name="UMVERSION">4</DAT>
<DAT name="U_BORD">N</DAT>
<DAT name="FRM_WIDGETTYPE">EGRID</DAT>
The column headers are label entries in the form's layout, one line above the fields:
&uFRM;TYP=E&uSEP;NAM=QPO_LIN.NOMODEL&uSEP;WID=110&uSEP;HEI=11&uSEP;HOC=110&uSEP;VOC=11&uFRM;
&uFRM;TYP=L&uSEP;NAM=L_SKU&uSEP;WID=13&uSEP;HEI=1&uSEP;LAB=Article&uFRM; ...
&uFRM;TYP=F&uSEP;NAM=L_SKU&uSEP;WID=13&uSEP;HEI=1&uFRM; ...
I generate these forms from Python, so this was the part to get right; in the IDE you simply drop the grid template on the form.
Rows
Rows are occurrences of the entity. Adding one appends an occurrence and makes it the current one:
entry DO_ADDROW
call VALIDATE_CURRENT
creocc "QPO_LIN", -1
call SETUP_ROW
INFO.QPO_FTR = "Row %%($curocc(QPO_LIN)) added."
return 0
end
A click into a row makes that row current, so "Remove row" removes exactly the row the user clicked:
entry DO_DELROW
variables
numeric vCur
endvariables
vCur = $curocc(QPO_LIN)
remocc "QPO_LIN", 0
if ($totocc(QPO_LIN) < 1)
creocc "QPO_LIN", -1
call SETUP_ROW
endif
call SHOW_TOTAL
INFO.QPO_FTR = "Row %%(vCur) removed."
return 0
end
Triggers per row
A loseFocus trigger on a grid field runs for the row the user just left. Field references without an occurrence number refer to that row, and $curocc tells you which one it is:
entry CHECK_ROW
variables
string vQty, vPrice, vHint, vError
numeric vNet
endvariables
if (L_PID.QPO_LIN = "")
return 0
endif
activate "PURIN_SVC".PO_LINE_CHECK($cSup$, L_PID.QPO_LIN, L_QTY.QPO_LIN, L_PRICE.QPO_LIN, vQty, vPrice, vNet, vHint, vError)
if ($status < 0)
L_NET.QPO_LIN = ""
INFO.QPO_FTR = "Row %%($curocc(QPO_LIN)): %%(vError)"
call SHOW_TOTAL
return 0
endif
L_QTY.QPO_LIN = vQty
L_PRICE.QPO_LIN = vPrice
sql "SELECT REPLACE(printf('%.2f', %%(vNet) / 100.0), '.', ',') AS T", "CUSTOMERS"
L_NET.QPO_LIN = $result
call SHOW_TOTAL
return 0
end
The running total walks over all rows inside the same trigger. I was not sure whether moving the current occurrence inside loseFocus would disturb where the cursor goes next. It does not, as long as the loop puts the old row back at the end:
vCur = $curocc(QPO_LIN)
vN = $totocc(QPO_LIN)
vI = 1
while (vI <= vN)
setocc "QPO_LIN", vI
if (L_PID.QPO_LIN != "")
L_PRICE.QPO_LIN = ""
call CHECK_ROW
endif
vI = vI + 1
endwhile
if (vCur > 0)
setocc "QPO_LIN", vCur
endif
(This loop is the one that re-prices all rows after the supplier changed.) In the click test the cursor always landed in the cell the user had clicked.
Surprise 1: field properties belong to a row
The name, unit and net columns are read-only. The first version set that once in exec. The first row was read-only, every row added later was editable again. The same happened with DblClk=Detail, which makes a double-click in an edit box fire the detail trigger: the article suggestions worked in row 1 and nowhere else.
Both $fieldsyntax and $fieldproperties act on the field in the current occurrence. So they go into an entry that runs after every creocc:
entry SETUP_ROW
$fieldsyntax(L_PID.QPO_LIN) = "NED"
$fieldsyntax(L_NAME.QPO_LIN) = "NED"
$fieldsyntax(L_UNIT.QPO_LIN) = "NED"
$fieldsyntax(L_NET.QPO_LIN) = "NED"
$fieldproperties(L_SKU.QPO_LIN) = "DblClk=Detail"
return 0
end
A side note: the older statement fieldsyntax L_NAME.QPO_LIN, "NED" still compiles, but the compiler reports it as deprecated (warning 1008). The $fieldsyntax function does the same without the warning.
Surprise 2: a button click does not fire loseFocus
In the click test I typed an article number and clicked "Add row" right away. The new row appeared, but the row I had just typed in was never checked: no name, no price. Leaving a cell by clicking a button did not fire the cell's loseFocus trigger.
The fix is cheap. Every button that relies on checked rows first checks the current row again:
entry VALIDATE_CURRENT
if (L_SKU.QPO_LIN != "")
call LEAVE_LSKU
endif
return 0
end
DO_ADDROW above calls it, and so does the save entry behind Ctrl+A. The save itself refuses rows that are still marked as wrong, so a half-checked line never reaches the service.
Saving
The save collects all filled rows into one item list (productId/quantity/price) and passes it to one service operation. That operation creates the purchase order through the existing purchasing service and rolls back if any line fails, so the user either gets the whole order or none of it.
Summary
- A non-database entity with
FRM_WIDGETTYPE = EGRIDgives an editable row list;creocc,remocc "ENT", 0,$totocc,$curoccandsetoccdo the rest. -
loseFocuson a grid field runs per row. A loop over all rows inside the trigger is fine if it restores the current row. -
$fieldsyntaxand$fieldpropertiesare per occurrence: set them for every new row. - Clicking a button does not fire
loseFocusof the cell you were in. Check the current row again before acting on the rows.
Top comments (0)