---
title: "Important: An organisational unit sorts its contracts on its own"
manual: "Academic Profiles"
version: "main"
permalink: "https://docs.typo3.org/permalink/fgtclb/academic-persons:important-organisational-unit-sorts-its-contracts@main"
source: "Changelog/2.4/Important-OrganisationalUnitSortsItsContracts.rst"
rendered: "2026-10-15T10:24:29+00:00"
---

# Important: An organisational unit sorts its contracts on its own {#important-organisational-unit-sorts-its-contracts}

## Description {#description}

A contract is an inline child of two records at once: of its profile, and of
its organisational unit. Both relations declared `foreign_sortby` as the
same `sorting` column.

`RelationHandler::writeForeignField()` numbers the children of the record
being saved 1..n in the order of its form, so saving an organisational unit
renumbered its contracts *across every profile that owns one of them*. An
editor who had arranged the contracts on a profile saw that arrangement
replaced by the order of an unrelated unit form. That happened in the backend
and, since a profile renders its contracts in `sorting` order, in the
frontend as well.

The organisational unit relation now has a sort column of its own,
`tx_academicpersons_domain_model_contract.organisational_unit_sorting`,
and orders by it. The profile keeps `sorting`, so nothing that renders
today changes.

## Impact {#impact}

Saving an organisational unit no longer changes the order of any profile, and a
profile no longer changes the order a unit form shows. Both arrangements are
kept side by side.

A contract that joins an organisational unit afterwards is appended to the end
of that unit's list, whether it was created in the unit form, given its unit in
the contract form on a profile, copied, localized, or created and edited in the
profile editing frontend of [`fgtclb/academic-persons-edit`](https://packagist.org/packages/fgtclb/academic-persons-edit). Changing
the unit moves it to the end of the new one. Clearing the unit removes it from
the list altogether.

The up/down sorting of the profile editing frontend is unaffected: it reorders
the contracts of a *profile* and writes `sorting`, which the profile
relation owns. The arrangement of an organisational unit is not touched by it.

The new column is added by [`ext_tables.sql`](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/FileStructure/ExtTablesSql.html#file-extension-ext-tables-sql). **Run the database
analyzer once after updating.** Every contract that existed before carries
`0` in it, so the upgrade wizard *Seed the contract sort order of academic
organisational units* fills it with the order the unit forms show today: the
current `sorting` of each contract, with `uid` settling ties. Run it
once in **Admin Tools > Upgrade > Upgrade Wizard**, or on the command
line:

```bash
vendor/bin/typo3 extension:setup
vendor/bin/typo3 upgrade:run academicPersons_seedContractOrganisationalUnitSorting
```

Until the wizard has run, a contract saved in the backend gets no position of
its own in the unit, because only the wizard knows the order the units show
today. Running the wizard again is harmless. It appends what has no position
yet and never renumbers what has one, so an arrangement made in a unit form is
not reset by it, and it reports nothing to do once every contract is seeded.

## Affected Installations {#affected-installations}

Every installation of this extension that assigns contracts to organisational
units.
