-
-
Notifications
You must be signed in to change notification settings - Fork 29
Mandatory Fields Developer Guide
How the mandatory-fields close gate is built, where it is enforced, and the traps that shaped it.
The user-facing page is Mandatory fields. It is the third close gate, alongside unfinished tasks (#83, warn only) and mandatory SOP steps (Checklists & SOPs - Developer Guide Β§5), and deliberately built the same way as the second.
Colour key: βοΈ shared Β· π API Β· π₯οΈ page Β· π i18n Β· π permissions
| π¨ | File | What it does |
|---|---|---|
| βοΈ | includes/services/mandatory_fields.php |
The rule. MandatoryFieldsService: the field registry, settings, missing(), assertClosureAllowed(), afterClosure()
|
| βοΈ | includes/tenant_settings.php |
The four SETTING_TICKET_MANDATORY_* keys |
| βοΈ | includes/services/tickets.php |
The hook in updateTicket(), and rowAfterUpdates()
|
| βοΈ | workflow/includes/engine.php |
The hook in action_set_ticket_status() - which does not use updateTicket()
|
| βοΈ | includes/template_email.php |
internalTicketEmail() - shared with SLA alerts |
| βοΈ | includes/email_log.php |
The closure_alert route |
| π | api/tickets/save_mandatory_fields_settings.php |
Saves the tab |
| π | api/tickets/get_mandatory_fields_check.php |
"What would be empty if this closed now?" - for the inbox dialog |
| π₯οΈ | tickets/settings/index.php |
The tab |
| π₯οΈ | assets/js/inbox.js |
assignStatus() + mandatoryFieldsCheck()
|
| π |
tickets/settings/manifest.php, includes/capabilities.php
|
The tab, Cap::TICKETS_MANDATORY_FIELDS (sensitive), and the setting keys it owns |
| π | lang/en/tickets.php |
settings.mandatory.*, mandatory_close.*, help.settings.card_mandatory_*
|
No schema change: the settings live in system_settings.
| Key | Value | Default |
|---|---|---|
ticket_mandatory_fields |
comma-separated keys of MandatoryFieldsService::FIELDS
|
empty - nothing required |
ticket_mandatory_mode |
warn / notify / block
|
warn |
ticket_mandatory_notify |
comma-separated addresses, validated, de-duplicated, at most 10 | empty |
ticket_mandatory_record |
1 / 0
|
1 |
All four are read through tenantSetting(), so a per-company override works on the reading side already. Only the tab is install-wide. Adding a company column means writing tenant_settings rows; nothing that reads them changes.
The save endpoint refuses an unknown field key or an invalid address rather than dropping it. A list that quietly saved as something other than what was typed is how an administrator comes to believe a rule is in force when it is not.
MandatoryFieldsService::FIELDS = [
'priority' => ['priority_id', 'Priority'],
...
'owner' => ['owner_id', 'Owner'],
...
];Key β tickets column and the English label used in the note and the email. The tab and the inbox use tickets.settings.mandatory.fields.<key> instead.
π΄ Owner, not analyst.
ticketsstores the assigned person twice, asassigned_analyst_idandowner_id.owner_idis what the screen reads and calls Owner, and every writer sets both. Listing both would offer one field twice under two names. Do not addassigned_analyst_id.
"Empty" is NULL or ''. For the two yes/no fields that means unanswered: 0 (No) is an answer and counts as filled in.
fieldAvailable():
| Key | Skipped when |
|---|---|
category / closure_category / resolution_code
|
the company's switch is off (ticketCategoryOn() and friends) |
team |
the install has no active teams - the inbox does not draw the picker |
Requiring a field the analyst has no way to fill would trap every ticket behind it. Add a row here if a new field ever gains its own switch.
The inbox, bulk actions, assign/schedule and the v1 REST API all close tickets through it.
// after every field has been resolved, BEFORE the UPDATE
$closing = $newStatusId !== null && $newIsClosed && !$oldIsClosed;
$afterRow = self::rowAfterUpdates($current, $updates, $args);
...
if ($closing) {
$emptyOnClose = MandatoryFieldsService::missing($conn, $closeTenant, $afterRow);
MandatoryFieldsService::assertClosureAllowed($conn, $closeTenant, $emptyOnClose); // may throw
}
// ... UPDATE ...
MandatoryFieldsService::afterClosure($conn, $ctx, $ticketId, $closeTenant, $emptyOnClose); // note + emailπ΄ Checked against the row AS IT WILL BE, not as it is. Against the stored row, a request that sets the resolution code and closes the ticket would be refused over the field it is filling in.
rowAfterUpdates()reads the values back out of the SET list, so it also sees what the service decides on its own: the category a type change clears, andowner_idwritten alongside the analyst. It skips values for fragments that are not plaincolumn = ?while keeping the arguments aligned.
π΄ Checked BEFORE the write, as the checklist gate is. Checked after, a
blockinstall throws with the ticket already closed.
The company also comes from $afterRow, so a ticket moved to another company in the same save is judged by that company's rules.
missing() is computed once, before the write, and handed to afterClosure(). Recomputing afterwards would describe the ticket after the save, which for a close is the same thing today. It stops being the same the moment anything else is written in between.
π΄ This action writes
status_iditself and never went throughupdateTicket(). So until this change the SOP checklist gate did not apply to workflows either, although its help card said it did. Both gates are now called here, before and after the write, in the same order.
A workflow has no analyst, so it acts as new ActorContext(0, null, 'workflow'). ticket_notes.analyst_id is NOT NULL with a foreign key to analysts, so actor 0 cannot write there: both services write a Workflow Note entry to ticket_audit with a NULL analyst instead. That is where the engine's own add note action already writes.
Under block the action throws ServiceError. The engine records it as a failed run with the message.
| Path | Why |
|---|---|
mergeTickets() |
closes the tickets merged away; refusing a merge over a ticket that is about to disappear helps nobody |
reopenTicketForCustomerReply() |
opens, never closes |
| Self-service | the portal cannot change a status |
Every way of closing a ticket calls confirmCloseWithMandatoryFields(ticketIds) first, which asks get_mandatory_fields_check.php and shows Close with fields empty? or Fill these in first:
| Path | Function |
|---|---|
| reading-pane status dropdown | assignStatus() |
| right-click β Status |
setStatusFromContext() (a selection goes through bulkSetField()) |
| drag onto a closed status |
handleTicketDrop() (several dragged go through bulkSetField()) |
| bulk action |
bulkSetField(), whenever fields.status is a closed status |
π΄ It first shipped wired to the dropdown alone (#1715), and Ed closed a ticket from the right-click menu within minutes with no warning (#1721). The server still enforced the rule, so the close was recorded, but the analyst was never asked. A new way of closing a ticket must call this helper, and
isClosedStatusName()is the test for whether a status change is a close.
The endpoint takes ticket_id or ticket_ids (up to 500; the inbox asks 100 at a time) and reports mode per ticket, because it resolves per company. For several tickets the dialog lists each with its empty fields. Where only some are refused it offers Close the rest: the server refuses the others and the bulk result names them. The inbox saves each field the moment it changes, so the stored ticket is what the close will be judged on.
β οΈ If the question fails, the inbox says nothing and sends the close anyway. The server enforces the rule again, so a failed check can never turn into a refusal nobody can clear. That is the same principle as the task warning: "a warning that cannot be shown must not become a block that cannot be cleared."
Any refused save now also puts the status dropdown back, so it never shows a status the ticket does not have.
internalTicketEmail($conn, $ticketId, $recipients, $subject, $html, $route) in includes/template_email.php was lifted out of sla_send_breach_email(), which now calls it. It picks the ticket's mailbox (or the first active one), handles Graph, Gmail and SMTP, does not save to Sent Items, and logs every recipient under $route.
It tries every recipient and throws the first failure at the end. Previously the SLA sender stopped at the first failure, so one mistyped address hid the alert from everybody listed after it.
afterClosure() never throws: a failed note or email must not turn a close that happened into an error. Failures go to error_log() and, for email, the send log.
Tests can replace the transport with MandatoryFieldsService::$mailer = fn($conn, $ticketId, $to, $subject, $html) => ....
Cap::TICKETS_MANDATORY_FIELDS, declared on the tab in tickets/settings/manifest.php with 'sensitive' => true, because the tab sends ticket details to any address typed into it. The four keys are listed as that tab's setting_keys, so settingKeyOwners() derives their owner from the same declaration and capSelfCheck() would flag a mismatch.
The tab's JavaScript lives in its own IIFE with the checklist handler, not in the Categories block. That block returns early when the Categories tab is absent, which had left the checklist Save button dead for any role granted Checklists but not Categories.
- Mandatory fields - the user page
- Checklists & SOPs - Developer Guide - the other close gate
- Ticket categories - Developer Guide - the per-company switches this respects
FreeITSM β an open-source IT Service Management platform Β· github.com/edmozley/freeitsm Β· MIT licence
- Installation
- β° Scheduled tasks (cron jobs)
- Architecture
- π§ͺ Developer tests
- AI Providers
- Internationalisation (i18n)
- Timezones & Time Handling
- π Date & Time Formats
- Theming & Dark Mode
- ποΈ Recent β getting back to what you were doing
- β¨οΈ Command palette (βK)
- π Searching inside tickets
- π Attached documents
-
MobileβFriendly
- β³ π« Mobile: Tickets
- β³ π» Mobile: Assets
- β³ π Mobile: Calendar
- β³ π Mobile: Knowledge
- β³ π¦ Mobile: Service Status
- β³ πΌ Mobile: Watchtower
- β³ π§© Mobile: Problem Management
- β³ π Mobile: Change Management
- β³ πΏ Mobile: Software
- β³ β Mobile: Tasks
- β³ π Mobile: Forms
- β³ π Mobile: Contracts
- β³ π Mobile: Domains
- β³ π Mobile: People
- β³ π Mobile: LMS
- β³ πΊοΈ Mobile: CMDB
- β³ πΊοΈ Mobile: Network Mapper
- β³ π§ Mobile: Process Mapper
- β³ βοΈ Mobile: Workflow
- β³ π₯οΈ Mobile: System
- β³ π Mobile: Reporting
- β³ π Mobile: System Wiki
- β³ π Mobile: Self-Service Portal
- β³ π§° Mobile: Techniques & Tricks
-
Security
- Layer 1 β which modules you can enter
- β³ π§© Module Access Control
- β³ π οΈ Module Access β Developer Guide
- Layer 2 β what you can administer
- β³ π Roles & Permissions
- β³ π οΈ Roles β Developer Guide
- β³ π€ Why capabilities are constants
- Layer 3 β the System module
- β³ π Admin Access Control
- Hardening
- β³ π Security review response 2026-08
- β³ π‘οΈ Security hardening 2026-08
- β³ π οΈ Security hardening 2026-08 β Developer Guide
- β³ π‘οΈ Round three β plain English
- β³ π οΈ Round three β Developer Guide
- β³ π‘οΈ CSRF protection (S4) β Developer Guide
- Single Sign-On (SSO)
- ποΈ LDAP & Active Directory
- π CardDAV contact sync
- Browser Extension
- API Reference
-
π REST API β how it works
- β³ π« REST API: Tickets
- β³ π» REST API: Assets
- β³ π΄ REST API: Problems
- β³ π REST API: Changes
- β³ π REST API: Knowledge
- β³ β REST API: Tasks
- β³ ποΈ REST API: CMDB
- β³ π REST API: Contracts
- β³ ποΈ REST API: Calendar
- β³ πΏ REST API: Software
- β³ π REST API: Domains
- β³ π¦ REST API: Service Status
- β³ βοΈ REST API: Morning Checks
- β³ π REST API: Forms
- β³ βοΈ REST API: Workflow
- β³ π·οΈ REST API: Cost centres
- β³ πΊοΈ REST API: Network Mapper
- β³ π§ Using the API docs page
- β³ π OpenAPI specification
- β³ β OpenAPI: kept correct
- β³ π οΈ Maintaining the catalogue
- Watchtower
-
Tickets
- β³ π Rota copy and paste β Developer Deep Dive
- β³ β Checklists & SOPs
- β³ βοΈ Mandatory fields
- β³ π·οΈ Ticket categories
- β³ π₯ Assigning tickets to a team, and escalation
- β³ π’ One board across every company
- β³ Mailbox Authentication
- β³ π€ Email send log
- β³ Basic IMAP mailboxes
- β³ Email rendering & images
- β³ SLA Management
- β³ WhatsApp channel
-
β³
βοΈ Telegram channel - β³ β CSAT company scope and filters β Developer Guide
- β³ π₯ Microsoft Teams channel
- β³ π¨οΈ Mattermost channel
- β³ π¬ Web chat channel
- β³ π£ Slack channel
- β³ π Linking tickets
- β³ β Record previews
- β³ π Ticket notes: internal or shared
- β³ ποΈ Canned responses
- β³ βοΈ Limiting replies to particular senders
- β³ π¨ Telling the analyst a ticket is theirs
- β³ βοΈ Email signatures
- β³ π The public web address
- β³ π’ Ticket numbering
- β³ π Raising a ticket for someone else
- β³ π Merging tickets
- β³ π Confidential tickets
- β³ π₯ Portal managers
- β³ π Who has seen a ticket
- β³ π Reading long tickets
- β³ β Splitting tickets
- β³ β Selecting several tickets
- β³ ποΈ The folder pane
- β³ π½ Just my tickets, or no closed ones
- β³ π οΈ Snoozing tickets β Developer Guide
- β³ π₯ Collision detection
- β³ β±οΈ Time tracking
- β³ π Scheduled work in your own calendar
- Problem Management
- Tasks
-
Assets
- β³ π’ Moving an asset between companies
- β³ π Shared asset locations
- β³ π§βπΌ Assigning assets to analysts
- β³ π Warranty and lease alerts
- β³ π Saved table views
- β³ π¨οΈ Recording anything, and importing it
- β³ π·οΈ QR asset labels
- β³ π Who holds what, and handover documents
- β³ π₯οΈ The inventory agent (PowerShell)
- β³ ποΈ Proxmox VE servers
- β³ βοΈ VMware Cloud Director servers
- β³ π Linking equipment to tickets
- β³ βοΈ Follow-up tasks on a ticket
- Knowledge
- Change Management
- Calendar
- Morning Checks
- Reporting
- Software
-
Forms
- β³ π¨ The form designer β Developer Guide
- β³ π Layout & the grid β Developer Guide
- β³ ποΈ Collections β grouping submissions
- β³ π Submissions as PDFs
- β³ β‘ What happens next β a form's own actions
- β³ π οΈ Sections & conditional logic β Developer Guide
- β³ π οΈ Lookup fields β Developer Guide
- β³ π‘οΈ Catalogue request approvals
- People
- Domains
- Contracts
- Service Status
- π Notifications
- π¨ War Room
- Self-Service Portal
- LMS
- Process Mapper
- CMDB
- Network Mapper
- Workflows
- Issue trackers (Jira, Azure DevOps)
- System
-
Overview
- β³ π Progress tracker
- β³ Concepts & vocabulary
- β³ Email routing & mailboxes
- β³ Settings: global vs per-company
- β³ Users & self-service
- β³ Staff cross-company access
- β³ π’ One board across every company
- β³ Worked examples
- β³ Pitfalls & gotchas
- β³ Scope: what it's for
- β³ π οΈ Developer Guide (make a module multi-company)
- β³ ποΈ Case study: CMDB (a linked graph)
- β³ π§ͺ Test harness (prove it's isolated)
- What this is
-
π Bugs resolved
- β³ π’ Chat tickets ignored your ticket numbering
- β³ π Dates shown as a dash, or in server time
- β³ π Assets β Users showed people from other companies
- β³ π Restricted analysts could read other modules' data
- β³ πΌοΈ Replies with a picture in the thread failed to send
- β³ π Reply attachments never reached the customer
- β³ π οΈ Outbound email attachments β Developer Guide
- β³ π A global SSO provider was missing from the portal
- β³ π Behind a proxy, the SSO redirect said http
- β³ βοΈ The portal tagline moved when you saved it
- β³ π¨ The portal settings screen forgot what you saved
- β³ π‘οΈ The approvals inbox said "Error" and nothing else
- β³ π A table's answers were missing from the PDF
- β³ β A single-select column let you tick every option
- β³ π The portal ignored a form's field widths
- β³ π The tasks board stopped taking clicks
- β³ ποΈ #121 The index list is out of date after upgrading
- β³ π #133 The calendar subscription was empty
- β³ π #131 Tasks always reopened on the board
- β³ π₯ #129 Every page returned HTTP 500 after upgrading
- β³ π³ #127 A PHP warning above the System page
- β³ π #126 Notes stamped with the server's clock
- β³ π Storing every date in UTC
- β³ πͺ The portal was down for everyone signed in
- β³ βοΈ #120 Workflow notes could never be written
- β³ βοΈ #123 Three errors when running Database Verification
- β³ π #122 The description box was a stub in the corner
- β³ π£ Demo data deleted real accounts
- β³ π #117 Sign-in redirected to the wrong address
- β³ π¨ #108 The priority dot was invisible
- β³ β±οΈ #116 Time logged from the right-click menu
- β³ π #114 API keys refused by our own guard
- β³ ποΈ #110 Assigning a task told nobody
- β³ πͺ #107 Signed out while still working
- β³ π #103 "Share with Requester" reached nobody
- β³ π #102 Search found nothing for hyphens
- β³ πͺ #101 Source code editor opened behind
- β³ βοΈ #88 Subtasks could not be ticked off
- β³ π» #84 Asset deep link selected nothing
- β³ π« #79 A new ticket arrived with no status
- β³ π§ #79 A ticket from email did not say so
- β³ π #78 Bell opened to nothing
- β³ π¬ #77 Mail only collected from Inbox
- β³ π #74 The default password could not be changed
- β³ π¦ #70 Renaming an impact level
- β³ π€ #67 App-only mailboxes could not send
- β³ π #45 Verify only ever worked for Microsoft
- β³ π #45 IMAP reported as not authenticated
- β³ βοΈ An email template stopped escaping itself
- β³ π The portal dashboard showed the wrong time
- β³ π’ The folder said 99 and the list showed 96