A Uniface 10 customer app has service tickets with five statuses. The existing ticket service enforces the allowed steps, which is good: every change is checked and written to a status log. For quick entry it is annoying, though. To close a ticket that is still open, a user has to go to "in progress", then "solved", then "closed" - three saves for one decision.
The quick entry form for tickets now lets the user type the target status (S for solved, C for closed) and walks the steps in between. The steps themselves still go through the existing service, so nothing bypasses its checks or its log.
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 allowed steps
The ticket service has an entry that says which single step is allowed:
if (pOld = "OPEN" & pNew = "IN_PROGRESS")
pOk = 1
endif
if (pOld = "IN_PROGRESS" & (pNew = "WAITING" | pNew = "SOLVED"))
pOk = 1
endif
and so on for WAITING and SOLVED. CLOSED is final.
Shortest paths, computed once
ProcScript has no queue type, and a breadth-first search in item lists would be hard to read. The graph is tiny and fixed, so I compute all shortest paths in the Python script that generates the service, and write them out as a chain of if blocks:
STEPS = {'OPEN': ['IN_PROGRESS'], 'IN_PROGRESS': ['WAITING', 'SOLVED'], 'WAITING': ['IN_PROGRESS', 'SOLVED'], 'SOLVED': ['CLOSED', 'IN_PROGRESS'], 'CLOSED': []}
def path(a, b):
from collections import deque
q = deque([(a, [])]); seen = {a}
while q:
s, p = q.popleft()
for n in STEPS[s]:
if n == b:
return p + [n]
if n not in seen:
seen.add(n); q.append((n, p + [n]))
return None
PATHS = ''
for a in STEPS:
for b in STEPS:
if a != b:
p = path(a, b)
if p:
PATHS += '\tif (pOld = "%s" & pNew = "%s")\n' % (a, b) + ''.join('\t\tputitem pSteps, -1, "%s"\n' % s for s in p) + '\tendif\n'
The generated operation is boring, which is the point. A part of it:
public operation STATUS_PATH
params
string pOld : IN
string pNew : IN
string pSteps : OUT
string pError : OUT
endparams
pSteps = ""
pError = ""
if (pOld = pNew)
return 0
endif
if (pOld = "OPEN" & pNew = "IN_PROGRESS")
putitem pSteps, -1, "IN_PROGRESS"
endif
if (pOld = "OPEN" & pNew = "WAITING")
putitem pSteps, -1, "IN_PROGRESS"
putitem pSteps, -1, "WAITING"
endif
if (pOld = "OPEN" & pNew = "SOLVED")
putitem pSteps, -1, "IN_PROGRESS"
putitem pSteps, -1, "SOLVED"
endif
if (pOld = "OPEN" & pNew = "CLOSED")
putitem pSteps, -1, "IN_PROGRESS"
putitem pSteps, -1, "SOLVED"
putitem pSteps, -1, "CLOSED"
endif
and it ends with:
if (pSteps = "")
pError = "The status cannot change from %%(pOld) to %%(pNew)."
return -1
endif
return 0
end
Pairs without a path (anything out of CLOSED, anything back to OPEN) simply produce no if block and end in that error. If the allowed steps ever change, I change STEPS and generate again; nobody has to re-derive the paths by hand.
Walking the path
The save operation of the quick entry receives all changed rows at once. For each row it gets the steps from the same check that the form uses for its preview, and then calls the existing service once per step:
forlist vStep in vSteps
activate "TICKET_SVC".SET_TICKET_STATUS(vId, vStep, pError)
if ($status < 0)
call GET_TEXT("SELECT TICKET_NO AS N FROM TICKET WHERE TICKET_ID = %%(vId)", vNo)
pError = "%%(vNo): %%(pError)"
rollback
pCount = 0
return -1
endif
vDone = 1
endfor
Because every step goes through SET_TICKET_STATUS, the status log contains one entry per step, exactly as if the user had clicked through them. The test service checks that: solving an open ticket leaves two log entries. If any step of any row fails, the whole save rolls back.
What the user sees
When the user leaves the "new status" cell, the row is checked and the hint line explains what will happen, for example status IN_PROGRESS > SOLVED assign: tst_admin time: 90 min. Nothing is written until the user saves with Ctrl+A.
A note on passing rows with free text
Each changed row travels to the service as one item: ticketId/status/assignee/minutes/note. The service splits the first four fields at / and takes the rest as the note, so a note may contain / itself. Putting the one free-text field last avoids an escaping scheme.
Summary
- Keep the single-step rules where they are; add a path on top instead of loosening them.
- For a small, fixed state graph, compute the paths in the generator and emit plain
ifblocks. The ProcScript stays trivial and the graph lives in one place. - Walk the path through the existing service so checks and logs stay complete, and roll back the whole batch on the first error.
Top comments (0)