Catalogue Request Approvals Developer Guide - edmozley/freeitsm GitHub Wiki
How catalogue-request approvals work, and why the shape is the way it is. Shipped as #928 (the gate + approver inbox + auto-raise) and #929 (the requester's dashboard view). Approval by a team, with a quorum came in 4.3.0 (GH #220) - see section 8.
The user-facing page is Catalogue Request Approvals.
Colour key: ๐๏ธ schema ยท โ๏ธ engine ยท ๐ API ยท ๐ฅ๏ธ UI ยท ๐จ CSS ยท ๐ i18n ยท ๐ docs
| ๐จ | File | What it does |
|---|---|---|
| ๐๏ธ | database/freeitsm.sql |
forms.requires_approval / approver_id; form_submissions.approval_status / approver_id / approval_decided_by_id / approval_decided_datetime / approval_comment; the four FKs to analysts
|
| ๐๏ธ | includes/db_verify_schema.php |
the same columns (columns only โ FKs live in freeitsm.sql) |
| โ๏ธ | includes/catalogue_approvals.php |
the engine. catalogueApprovalDecide(), catalogueCreateTicketFromSubmission(), catalogueApprovalsList(), catalogueApprovalGate(), catalogueSubmissionBodyHtml()
|
| โ๏ธ | includes/services/forms.php |
FormsService::submitForm() gates the submission; saveForm() stores the per-item settings |
| ๐ | api/forms/catalogue_approvals.php |
the inbox list (?filter=mine|all|decided) |
| ๐ | api/forms/decide_catalogue_approval.php |
approve / reject one request (a vote, in team mode); override: true for an administrator's override (#220) |
| ๐ | api/forms/move_catalogue_approval.php |
an administrator moves a waiting request to another team or person, with a reason (#220) |
| ๐ | api/forms/approval_teams.php |
active teams with member counts, for the approval window and Move (#220) |
| ๐๏ธ |
form_submission_votes, form_submission_approval_events
|
one row per team vote; one row per override or move (#220) |
| โ | tests/catalogue-group-approvals.php |
the team engine end to end, including two votes landing at once (#220) |
| ๐ | api/forms/save_form.php |
unchanged โ passes requires_approval / approver_id straight through to the service |
| ๐ | api/forms/get_forms.php |
returns the approval columns + approver_name for the list |
| ๐ | api/self-service/get_dashboard.php |
returns the requester's requests[] with their state (#929) |
| ๐ฅ๏ธ | forms/index.php |
the ๐ก๏ธ shield button, the Approval settings modal, the amber pill |
| ๐ฅ๏ธ | forms/approvals.php |
the approver inbox (cloned from change-management/approvals.php) |
| ๐ฅ๏ธ | forms/includes/header.php |
the Approvals nav item |
| ๐ฅ๏ธ | self-service/index.php |
the Your requests dashboard section (#929) |
| ๐ |
lang/en/forms.php + lang/pt-BR/forms.php
|
the approval block, same commit |
| ๐ |
lang/en/self-service.php + lang/pt-BR/self-service.php
|
the dashboard req_* keys (#929) |
| ๐ |
CHANGELOG.local.md, this wiki |
#928 / #929 |
There is no new table: a catalogue item is a forms row and a request is a form_submissions row, so the approval state hangs off columns on those, mirroring how is_portal_visible was added.
The classic version routes a request to the requester's line manager. Portal users (users) have no manager relationship โ only tenant_id (their company) โ so v1 reuses Change Management's single-approver idea instead: one analyst signs a catalogue item off.
The Change approval code is a good template but nothing is shareable: it's welded to the changes table and to analysts, with status-name string literals. So this is a parallel, smaller implementation of the approver + inbox pattern from Change Management.
FormsService::submitForm() decides at submit time whether to gate, through one function for both ways of deciding:
$gate = catalogueApprovalGate($form, $portalUserId);
$approvalStatus = $gate !== null ? 'pending' : 'not_required';catalogueApprovalGate() returns the policy to snapshot (approver_id, approval_team_id, approvals_required, rejections_required, approval_exclude_requester) or null. Three deliberate rules live in it:
-
Portal only (
$portalUserId !== null). The feature auto-raises a ticket for the requester; an analyst filling a form internally has none, so it's never gated. -
Unconfigured โ gated.
requires_approvalon with neither a team nor anapprover_idfalls through tonot_requiredโ a form must never strand a request with nobody able to clear it. -
The policy is snapshotted onto the
form_submissionsrow here, not read from the form at decision time. Editing the catalogue item later re-routes future requests, never ones already waiting - and never lowers the bar for one.
๐ A gated submission fires
catalogue_request.submitted, NOTform.submitted. An admin's create-ticket workflow rule onform.submittedwould otherwise raise the ticket immediately and jump the gate. The outcome events arecatalogue_request.approved/.rejected. All three are best-effort (guarded byclass_exists('WorkflowEngine')and try/catch) โ notification is a bonus, never the mechanism.
catalogueApprovalDecide($conn, $actorId, $submissionId, $decision, $comment):
- Loads the submission; refuses if it isn't
pending. - Refuses unless the actor is
approver_idโ orsessionIsAdmin(). (Team mode is different: section 8.) - On approve, inside one transaction: raise the ticket, then stamp
approval_status='approved',approval_decided_by_id, timestamp, comment andticket_id. On reject: the same minus the ticket.
catalogueCreateTicketFromSubmission() deliberately mirrors api/self-service/create_ticket.php โ the correct portal path:
- requester resolved by
users.id(never an email string โ that's the bug inWorkflowEngine::action_create_ticket()); - company from the requester's own
tenant_id, falling to NULL/Default exactly as the portal's new-ticket path does; - status
Open, the install's default priority; - body built by
catalogueSubmissionBodyHtml()โ the answers as a fully-escaped table, so a customer's field values can't inject markup into the analyst's reading pane.
๐ This is also where promote-to-ticket finally landed.
form_submissions.ticket_idhad been a reserved "not yet actioned" column that nothing wrote. The approve path is its first writer.
forms.submission_actions is one TEXT column holding JSON:
{ "submitted": [ {"type":"create_ticket","args":{โฆ}} ], "approved": [โฆ], "rejected": [โฆ] }Each list is {type, args} in the workflow engine's own action shape, because they are workflow actions โ WorkflowEngine::runActionList() runs them through the same executeActionList() loop a stored workflow uses, so chaining ({{last.ticket_id}}), error isolation and the step log all behave identically. JSON-in-TEXT for the same reason workflows.actions is: no migration each time a new action kind lands.
Runs are written to workflow_executions with workflow_id NULL and the form's name in workflow_name (the column is nullable and carries a name snapshot exactly so a run can have no parent row). Without that, a form's automation would be the one kind nobody could audit โ and "it didn't do anything and I can't see why" is the worst failure mode automation has.
Executed from FormsService::submitForm() and catalogueApprovalDecide(), never from an adapter, so the UI, the portal and REST API v1 behave identically without any of them knowing the feature exists.
| Stored | Means | Behaviour |
|---|---|---|
NULL |
never configured | pre-#95 behaviour: nothing on submit; an approval raises a ticket the hard-coded way |
[] |
somebody opened the panel and chose nothing | obeyed โ an approval raises no ticket |
| a list | configured | the list runs instead of the hard-coded raise |
This is the whole safety argument. Every form that existed before the upgrade has NULL and keeps doing exactly what it did, so no data migration seeds anything and nothing can be half-migrated. The alternative โ seeding every gated form with a create_ticket action โ had two failure modes (a form missed by the seed silently stops raising tickets; a form seeded and still running the hard-coded path raises two) and this design has neither.
โ ๏ธ A configuredapprovedlist raises its ticket AFTER the commit, not inside the decision transaction like the hard-coded path. An action list can send email, and a rolled-back email is still an email somebody received. The submission'sticket_idis stamped afterwards from thecreate_ticketstep's result โ that column is what the requester's Your requests panel reads, so a request showing no ticket after one was raised would look like a failure.
โ ๏ธ A gated submission runs nosubmittedlist, for the same reason it fires a different event: raising a ticket at submission time steps straight over the gate.
โ ๏ธ submission_actionsis written bycreateVersion(). Leaving it out would repeat the exact fault below โ a per-form setting that Save deletes โ except this time the form would quietly stop raising tickets.
โ ๏ธ Saving validates everytypeagainstWorkflowEngine::availableActions(). An unknown type stored here would fail at run time inside a form submission, where the person who typed it will never see the error.
โ ๏ธ Three faults this shipped with โ fixed under discussion #95
All three were found while working out where form-submission actions should live. None had been reported: each one fails silently, which is what made them survive.
FormsService::createVersion() copies the leaf into a new row, and its INSERT named title, description, is_active, is_portal_visible โ not requires_approval or approver_id. requires_approval defaults to 0, so the new version came out ungated.
The catalogue lists leaves, so the ungated copy is the one the portal offers from that moment. Two behaviours changed at once and neither announced itself: sign-off stopped being required, and โ because the approve path is the only thing that raises the ticket โ requests stopped becoming tickets at all.
๐ The general shape: a per-form setting that does not travel through
createVersion()is a setting that Save deletes. The fix carries both columns;approver_idis passed as NULL rather than 0, because "nobody assigned" is a real state the gate reads as unconfigured.
โ ๏ธ Not retrospectively repairable. A form edited before the fix lost the value at the moment of editing; there is nothing to recover it from. Any install that used approvals needs its forms checked by hand.
catalogueApprovalDecide() dispatches catalogue_request.approved / .rejected, and FormsService::submitForm() dispatches catalogue_request.submitted for a gated request. None of the three was in WorkflowEngine::availableTriggers().
dispatch() matches on trigger_event, and the editor's trigger dropdown is built from availableTriggers() โ so no workflow could ever hold one of those values, and every dispatch matched zero rows. The code comments describe these as the hook to notify the approver and to tell the requester the outcome. Neither could happen; an approver had to think to go and look.
๐ A
dispatch()call is only half a trigger. The catalogue entry is the other half, and nothing links them โ no error, no warning, no failing test. Adding adispatch()without theavailableTriggers()line produces an event that exists and can never be heard.
catalogue_request.**rejected**, not .declined. The name is built as 'catalogue_request.' . $decision, and $decision is validated against ['approved','rejected'] โ the same word the column, the API contract and the UI button all use.
The decide dispatch carried form and request (comment, ticket id, ticket number) but no submission. So {{submission.fields.Device type}} resolved to nothing on approve/reject while working fine on form.submitted โ the same merge code meaning two different things depending on when it ran.
catalogueSubmissionAnswerMap() now supplies the label-keyed map plus the first email answer, and the four form-shaped triggers share one SUBMISSION_FIELD_TRIGGERS const so the merge-code hint and the editor's unknown-variable warning can't drift apart.
โ ๏ธ catalogueSubmissionAnswerMap()andcatalogueSubmissionAnswers()are not duplicates and must not be merged. The map is keyed by label because a merge code addresses an answer by name; the list is ordered because the approval card renders every row. A map cannot represent two fields sharing a label โ the second would silently swallow the first โ so the card keeps its list.
โ ๏ธ Values in the map go throughcatalogueAnswerText(), so a checkbox readsYes/No.form.submittedstill flattens raw (1/0). Unifying them changes what already-built rules receive, so it is a deliberate decision rather than a tidy-up.
-
Config (
forms/index.php): the shield button opens a self-contained modal (#approvalModal). Active analysts are fetched once fromapi/tickets/get_analysts.php. Save posts only{id, requires_approval, approver_id}โ a partial update, the same contract as the portaltogglePortal, so nothing else about the form is touched. -
Approver inbox (
forms/approvals.php): cloned fromchange-management/approvals.phpโ filter sidebar (mine/all/decided) + card list, each card showing the answers and Approve/Reject with an optional note.showToastcomes from the shared header, so the page doesn't loadtoast.jsitself. -
Requester view (
self-service/index.php, #929): a Your requests section, hidden until the dashboard payload carries any.api/self-service/get_dashboard.phpreads them in a guarded query โ a pre-upgrade instance without the approval columns degrades to no requests rather than a broken dashboard.
-
php -lacross every changed file. -
Engine end-to-end against the dev DB: seed a pending request โ
catalogueApprovalsListshows it โcatalogueApprovalDecide(approve)raises a ticket, stampsticket_id, setsapproved; requester (user_id), company and the answers-in-body all correct; re-approve and wrong-approver both refused with their specific messages. - Both analyst pages rendered with a forged analyst session (HTTP 200, no PHP errors), inline JS parsed clean in headless Chrome.
- #929:
get_dashboard.phpreturns the three states (pending / approved+ticket_number / rejected) via a forged portal session; the dashboard renders clean.
-
Manager-based routing โ the headline next step. Needs
users.manager_id(or equivalent) and a way to populate it (LDAP/SSO/manual), then gate on the requester's manager instead of a fixed analyst. That relationship is its own mini-project. -
Several stages ("line manager, then finance") - built in 5.10.0 as approval steps and chains, on exactly this
approval_roundidea: see Approval steps and chains - Developer Guide. -
Show the rejection reason to the requester โ the note is stored (
approval_comment); surfacing it on the portal is a product decision (flip the approver's note from internal to requester-visible). -
Attachments โ forms have no file fields today; if they gain uploads, carry them onto the ticket in
catalogueCreateTicketFromSubmission()(the pattern is increate_ticket.php). -
A "raise ticket" button for NON-gated submissions โ
forms/submissions.phpstill has none; the approve path only covers gated ones.
The design, the questions and Ed's answers are on Catalogue Group Approvals - Design. This section is how the code does it.
| Where | Columns | Notes |
|---|---|---|
forms |
approval_team_id (FK teams, SET NULL), approvals_required (default 1), rejections_required (default 1), approval_exclude_requester (default 0) |
the policy as configured. approver_id is kept when a team is chosen, so switching back restores the person |
form_submissions |
the same four (nullable), plus approval_round (default 1) |
the snapshot. approval_team_id set = team mode; NULL = person mode, exactly as before |
form_submission_votes |
submission_id, approval_round, analyst_id, decision, comment, was_member, voted_datetime
|
unique (submission_id, approval_round, analyst_id) - one vote per person per round, enforced by the database |
form_submission_approval_events |
submission_id, analyst_id, action (moved / override_approved / override_rejected), detail, reason, event_datetime
|
the administrator's interventions |
๐ Nothing existing changes on upgrade. Every new column defaults to "behave as before": no team, one approval, one rejection, requester not excluded. A form with a named approver produces a submission with
approval_team_idNULL and goes down the original path. No data migration.
โ ๏ธ Before Database Verification the columns do not exist.catalogueTeamApprovalAvailable()checks for them once per request, and every team read and write is behind it - the install then behaves exactly as 4.2.0.
catalogueApprovalPolicy($sub) reads only the submission row: mode, team, the two numbers, exclude_requester (always true in team mode) and the round. Nothing at decision time reads the forms row.
catalogueEligibleMembers() - active members of an active team, less the requester - is asked at every vote, not snapshotted. Membership is the thing an organisation changes when somebody leaves, and a leaver should lose their vote on what is still waiting. Votes already cast keep counting; was_member records that the voter was eligible when they voted.
The requester is matched by email (catalogueAnalystIsRequester()): users and analysts are separate tables, so the only link between a portal requester and a member of staff is the address. Lower-cased and trimmed; an empty address never matches.
catalogueApprovalDecide() runs in a transaction that starts with catalogueLockSubmission() (SELECT ... FOR UPDATE). In team mode it:
- refuses unless the request is still
pending; - refuses unless the actor is in
catalogueEligibleMembers(); - refuses a rejection with no reason;
- inserts the vote - a duplicate-key error becomes You have already decided this request;
- recounts with
catalogueApprovalProgress(); if approvals or rejections reached their number, finishes the decision inside the same transaction; otherwise returnsdecision: 'recorded'with the progress.
๐ TRAP: the row lock is what stops two tickets. Two final votes landing together would otherwise each see "one short", each tip it, and each raise a ticket. With the lock the second waits, then finds the request decided.
tests/catalogue-group-approvals.phpfires two votes from two processes at once and checks for exactly one ticket.
Finishing is split in two, as the hard-coded path always was:
-
catalogueFinishDecision()- inside the transaction: raise the ticket (or nothing on reject) and stamp the submission. -
catalogueAfterDecision()- after the commit: the workflow dispatch and the form's own When approved / When rejected list. Email sent from inside a transaction that then rolls back is still email somebody received.
catalogueApprovalProgress() sets stuck when neither number can be reached any more: approvals + still-able-to-vote < approvals_required and rejections + still-able-to-vote < rejections_required. Also for person mode with no approver (a deleted team or analyst set it NULL) or an excluded requester. A stuck request is only ever flagged - never auto-approved, auto-rejected or re-routed. That is an administrator's call.
-
Override (
catalogueApprovalOverride(),override: trueon the decide endpoint): administrator only, team mode only, reason required. It finishes the decision through the same two functions and writes anoverride_*event. On a person request an administrator's click already decides it, so there is nothing to override. -
Move (
catalogueApprovalMove(),api/forms/move_catalogue_approval.php): administrator only, reason required, to a team (with its ownapprovals_required) or a person. It rewrites the snapshot and incrementsapproval_round- earlier votes stay in the table but are no longer counted, because the new approvers were not the ones asked. Writes amovedevent withcatalogueRoutingLabel()of before and after.
๐ An administrator's ordinary Approve in team mode is not a vote. That was Ed's decision: an admin who happens to pass by should not quietly count as one of the "two different people". If the admin is a team member they vote in For me like anyone else; otherwise the card says the click overrides and needs a reason.
catalogueApproverCanEnter() and sessionIsFormApproverOnly() let a member of an approving team open Forms โ Approvals without Forms access, the same as a named approver (catalogueAnalystApprovesAsTeam()). catalogueApprovalsList()'s mine adds team requests the analyst can still vote on; decided adds requests they have voted on. Each item carries mode, progress, can_vote, can_decide, can_override, can_move, events and approval_team_name, and the page shows buttons only where they would work.
FormsService::saveApprovalPolicy() runs after saveForm()'s update and insert. It touches only the keys sent, checks the team exists and is active, and bounds both numbers to 1-20. copyApprovalPolicy() carries the four columns through createVersion() - the lesson of fault 1, not repeated.
catalogue_request.submitted carries approval_team in team mode, beside approver in person mode. .approved / .rejected fire once, when the request is decided - not on each vote.
Slice 1 of Catalogue as a shop, contributed by vsc55 in PR #349. A catalogue item gets a picture, a one-line summary and a price; a request keeps the price; Your requests lists every request; the requester can cancel one awaiting approval.
| ๐จ | File | What it does |
|---|---|---|
| โ๏ธ | includes/catalogue_card.php |
the card. catalogueCardAvailable(), catalogueCardFromInput(), catalogueCardSave(), catalogueCardCopy(), catalogueImageBelongs(), catalogueRequestPrice(), cataloguePriceLabel(), catalogueRequestPriceLabels(), catalogueCardForPortal(); enum CataloguePricePeriod (once / month) |
| โ๏ธ | includes/catalogue_approvals.php |
catalogueRequestCancellable(), catalogueCancelRequest(), catalogueAfterCancel(); catalogueRaiseTicketFromSubmission() refuses cancelled
|
| โ๏ธ | includes/services/forms.php |
saveForm() calls catalogueCardSave(); createVersion() calls catalogueCardCopy(); submitForm() snapshots the price (portal requests only) |
| ๐ | api/forms/card_image.php |
serves the picture by form id |
| ๐ | api/self-service/cancel_request.php |
POST {submission_id, reason} - the requester cancels |
| ๐ | api/self-service/get_dashboard.php |
requests[] now every catalogue request, each with price_label, can_cancel and (only when cancelled) approval_comment
|
| ๐ |
api/self-service/get_catalogue.php, get_catalogue_form.php
|
the card for the portal - never the stored path |
| ๐ |
api/v1/resources/forms.php, api/v1/spec.json, api/v1/lib/openapi_schemas.php
|
the card on GET /forms and /forms/{id}; the writable keys |
| โ๏ธ | workflow/includes/engine.php |
catalogue_request.cancelled in availableTriggers(), its fields, and SUBMISSION_FIELD_TRIGGERS
|
| ๐ฅ๏ธ | forms/edit/index.php |
the Catalogue tab and its live card; saveForm() lets a form with no question save once it has a price, a summary or a picture (forms.save.need_field_or_item otherwise) - the rule is the editor's |
| ๐ฅ๏ธ |
forms/index.php, forms/approvals.php
|
the price pill; the price on an approval card |
| ๐ฅ๏ธ |
self-service/catalogue.php, self-service/index.php
|
the portal card; Your requests with Cancel and its dialog |
| โ | tests/catalogue-card.php |
71 checks, including HTTP checks of card_image.php and get_catalogue
|
| Where | Columns | Notes |
|---|---|---|
forms |
catalogue_summary VARCHAR(255), catalogue_price DECIMAL(18,2), catalogue_currency VARCHAR(3), catalogue_price_period VARCHAR(10), catalogue_image_path VARCHAR(100)
|
all NULL = the card as before. NULL currency = the install's; NULL period = once. The path is <formId>/<32 hex>.<ext>, as upload_image.php writes it |
form_submissions |
catalogue_price, catalogue_currency, catalogue_price_period
|
the price as requested, snapshotted, never read live |
A cancelled request needs no new column: approval_status = 'cancelled', approval_comment = the reason, approval_decided_datetime = when. approval_decided_by_id stays NULL - it names an analyst, and the requester is submitted_by_user_id.
function catalogueCardAvailable(PDO $conn): bool // static-cached per request
// true only when BOTH forms.catalogue_image_path AND
// form_submissions.catalogue_price_period exist (information_schema)Both tables, so a half-run Database Verification never writes a price the request cannot keep. Every save, copy, snapshot and label is behind it; card_image.php returns 404 without it. Before it is true, an upgraded install behaves exactly as 5.3.0.
๐ Only the keys sent are touched.
catalogueCardFromInput()builds theSETlist fromarray_key_exists(), so the REST API or an older page that saves a form without the card never clears it.''ornullclears one key. The summary is stripped to plain text on one line; the price is a number from 0 to 1,000,000,000, stored to 2 places; the currency goes throughmoneyServiceCurrency(); the period throughCataloguePricePeriod::tryFrom()(onceis stored as NULL).
โ ๏ธ TRAP:createVersion()must copy the card (catalogueCardCopy()). A per-form setting left out of the version copy is one that pressing Save deletes - the fault that once removed approval gating (fault 1).
GET api/forms/card_image.php?form=<forms.id>. The same rules as image.php, which serves an image block:
-
A form id, never a path. The path is read from
forms.catalogue_image_path. -
Who: an analyst needs the Forms module (checked after the lookup, so both refusals look the same); a portal user only gets an item in their catalogue, with the gate in the query -
is_portal_visible = 1,is_active = 1, the current version (no child row), andFormsService::portalAudienceSql(). Nobody signed in gets nothing. -
The stored path is checked again before a byte is read:
CATALOGUE_IMAGE_PATH_RE(~^([0-9]+)/([0-9a-f]{32})\.([a-z0-9]{1,5})$~), the extension inUPLOAD_TYPES_IMAGE, andcatalogueImageBelongs()- the form id in the path is this form or one of its earlier versions (walked upparent_form_id, bounded at 500 steps). A value from our own upload endpoint is still a value from a database row. -
Every refusal is the same 404 (
Not found), never a 403, so a refusal never says which ids are real. -
Content-Typefrom our whitelist, never the file;X-Content-Type-Options: nosniff;Cache-Control: private, max-age=3600(an item may be for some people only, so no shared proxy keeps it).catalogueCardForPortal()adds&v=from a hash of the path, so a new picture shows at once rather than when the cached one expires.
The upload itself is api/forms/upload_image.php, unchanged - the image-block type whitelist, no SVG, 4 MB. The file lands in forms/images/<formId>/ (denied to direct web access on Apache and IIS by the folder's .htaccess / web.config) and, on Docker, on its own forms-images volume since PR #350.
FormsService::submitForm() takes catalogueRequestPrice($form) for a portal request only - an analyst filling the form in is not buying anything. A blank currency is resolved to Money::defaultCurrency() now, so a later change of the install's currency cannot turn last year's ยฃ40 into โฌ40. cataloguePriceLabel() is the one way it is written for a person (ยฃ25.00, ยฃ10.00 a month, Free); catalogueRequestPriceLabels() reads a list of requests' prices in one query for the approvals inbox and Your requests. The ticket an approval raises carries a Price line under "Submitted via".
function catalogueRequestCancellable(array $sub): bool
// a catalogue request (no for_ticket_id, no task_id) AND approval_status === 'pending'
function catalogueCancelRequest(PDO $conn, int $userId, int $submissionId, string $reason): void
// @throws ServiceError not_found | validation | conflict- The reason is tidied to one line and required (
missing_field), at most 1000 characters. - In a transaction,
SELECT * FROM form_submissions WHERE id = ? FOR UPDATE- the same lock a decision takes, so a cancel and an approval landing together cannot both win: the second finds the row no longerpending. - Not the caller's request, a form filled in on a ticket or in a task, or no such row:
not_found- never "not yours". - Not cancellable:
conflict, with its own message - already cancelled, already decided, or (for anot_requiredrequest) already sent - reply on its ticket, or contact the service desk. -
UPDATE ... SET approval_status = 'cancelled', approval_decided_by_id = NULL, approval_decided_datetime = UTC_TIMESTAMP(), approval_comment = ?, commit. -
After the commit,
catalogueAfterCancel($conn, $sub, $reason).
api/self-service/cancel_request.php is POST only with CSRF (csrfRequireWriteMethod()), needs a portal session and the Forms module, shows a ServiceError's message (written for the person cancelling) and never an exception's own text.
๐ Only while awaiting approval (Ed, 15 November 2026). As submitted, a
not_requiredrequest with no ticket could be cancelled too; old sent requests - often handled long ago by email or a webhook - would then have carried a Cancel link for ever. They are still listed, as Sent, withcan_cancelfalse.
Best-effort, like every catalogue event: guarded by class_exists('WorkflowEngine') and a try/catch that only logs, so a failure never undoes the cancel. It dispatches catalogue_request.cancelled with:
[
'form' => ['id' => <form_id>, 'name' => <title>],
'request' => ['id' => <submission id>, 'reason' => $reason, 'comment' => $reason],
'submission' => ['id' => <submission id>, 'email' => ..., 'fields' => [label => answer, ...]],
// from the request's snapshot (catalogueApprovalPolicy($sub)), as .submitted named them:
'approver' => ['id' => <analyst id>], // person mode only
'approval_team' => ['id' => <team id>, 'approvals_required' => <n>], // team mode only
]request.comment duplicates the reason so a message template written for .rejected reads it unchanged. The event is in availableTriggers(), has its fields registered (form.id, form.name, request.id, request.reason, request.comment, submission.email, approver.id, approval_team.id) and is in SUBMISSION_FIELD_TRIGGERS, so {{submission.fields.<label>}} works on it. dispatch() with no catalogue entry is an event nobody can hear (fault 2).
catalogueRaiseTicketFromSubmission() - what Create a ticket calls - refuses cancelled beside pending and rejected (That request was cancelled by the requester, so no ticket was raised), so a rule on this event can never raise the withdrawn ticket.
get_dashboard.php lists the requester's last 15 form_submissions, any approval_status, newest first, leaving out forms filled in on a ticket (for_ticket_id) or in a task (task_id). Each column is named only once Database Verification has added it - TicketForms::columnsReady() / TaskForms::columnsReady(), the cached per-request checks every form_submissions reader uses, not an information_schema query per load. approval_comment is sent only for a cancelled request (the requester's own reason); an approver's note on a decision stays internal, as before.
apiSerializeForm() adds catalogue_summary, catalogue_price (a number or null), catalogue_currency (null = the install's), catalogue_price_period (once / month, null when there is no price) and catalogue_has_image (bool) - never catalogue_image_path. POST /forms and PATCH /forms/{id} accept the first four through catalogueCardFromInput(); apiFormsWritableBody() drops catalogue_image_path, because the API has no upload and the stored path is internal. See REST API: Forms.
The next slices are on the design: the requester's manager as approver (a third approval mode, snapshotted on the request like the others), the item's responsible team / analyst for the ticket an approval raises, and the cost centre kept with the request. A new per-item column goes in catalogueCardCopy() - or its own copy in createVersion() - the day it is added.
- Catalogue Request Approvals โ the analyst-facing page
- Catalogue Group Approvals - Design โ GH #220: the request, the decisions, the acceptance criteria
- Portal Request Catalogue โ how a form becomes a catalogue item
- Self-Service Developer Guide โ portal internals and the rules when extending it