Skip to content

PR 401 Change Editor Used Hardcoded Lookups

Ed Mozley edited this page Nov 19, 2026 · 1 revision

πŸ” PR #401 The change editor ignored your configured priorities, types and impacts

GitHub PR #401, found and fixed by @Dr4inder Β· Change Management Β· fixed in 5.7.0 (#3011)

What you saw

Rename a change priority under Change Management β†’ Settings β†’ Priorities - High to Hoch, say - then open a change and click Save. The save failed with "Unknown priority: High", even though nobody had chosen anything called High. Change type and impact did the same. Other symptoms of the same fault:

  • a priority, type or impact you added never appeared in the editor;
  • editing a change whose value was not one of the built-in ones could quietly change it;
  • a template that set a priority, type or impact you had added could not select it, because the form never had that option.

The right-click menu on the change list was fine all along. It already used your configured lists.

What was wrong

The three dropdowns in the editor (change-management/index.php) were written into the page by hand:

<select class="form-input" id="changePriority">
    <option value="Low">…</option>
    <option value="Medium" selected>…</option>
    <option value="High">…</option>
    <option value="Critical">…</option>
</select>

The text you saw was translated, but the value sent on save was the fixed English word. The server looks a change's priority up by name in change_priorities, so once High was renamed there was nothing called High left to find, and the save was refused. The lookups have been configurable for a long time; the editor was the last place that never asked for them.

The fix

@Dr4inder's change fills all three dropdowns from the same lookup endpoints the right-click menu uses (get_change_priorities.php, get_change_types.php, get_change_impacts.php), in your configured order. From assets/js/change-management.js:

/** Use configured names, retaining an existing inactive value only on that change. */
function populateChangeLookup(id, rows, currentValue = null) {
    const select = document.getElementById(id);
    select.replaceChildren(...rows.map(row => new Option(row.name, row.name)));
    const value = currentValue === null
        ? (rows.find(row => row.is_default) || rows[0])?.name || ''
        : currentValue;
    if (currentValue !== null && !rows.some(row => row.name === value)) {
        select.add(new Option(value, value));
    }
    select.value = value;
}
  • A new change starts on the value marked Default, or the first active one if none is.
  • Editing keeps the change's current value even when that value has since been made inactive, without offering it for new changes.
  • New and Edit wait for the three lists to load. If they cannot load, you get "Could not load change types, priorities and impacts. Reload the page and try again." rather than an editor offering the wrong choices.

What I added on top

The PR was merged as written. On top of it, I translated the new error message into the eight other languages FreeITSM ships at 100%.

⚠️ One visible difference

The editor now shows each name exactly as it is stored, as the right-click menu always has. If you run FreeITSM in another language and never renamed the seeded values, the editor now says High where it used to show your language's word for it. Renaming the values under Settings in your own language fixes that, and saving keeps working because the name and the stored value are now the same thing.

πŸ“ Files

File Change
🟑 assets/js/change-management.js populateChangeLookup(); New and Edit wait for the lists
🟑 change-management/index.php The three dropdowns start empty; change-management.js?v=41
βšͺ lang/*/change-management.php toast.lookup_load_error
🟒 tests/change-editor-lookups.php 13 browser checks

How it was verified

tests/change-editor-lookups.php runs the real editor markup and JavaScript in headless Chrome: configured names, order and defaults, an inactive value kept on edit, names with special characters, templates, the values actually submitted, and failed lookup requests. It fails 11 of 13 checks on the old code and passes 13 of 13 with the fix. I reran it on a test install before merging.

What this means for you

Update to 5.7.0 and hard-refresh (Ctrl-F5). Rename, add or reorder priorities, types and impacts as you like; the editor follows.

Related: Change Management Β· Change Management - Developer Guide

FreeITSM

Getting Started

Modules

Multi-tenancy (planned)

Responses to feedback

Blue sky thinking

Bugs resolved

Pull requests

Links

Clone this wiki locally