Postman collection
Invoices Write

pixiInvoiceSetTrackingID

Sets or adds shipment tracking IDs for an invoice and its packages, optionally replacing existing ones and resetting the client-notified flag.

Assigns one or more tracking IDs to an invoice (Invoices.ShipmentTrackingID) and its packages (pixi.InvoicePackage).

  1. Invoice lookup: InvoiceNR is matched against Invoices.InvoiceNr. If it contains -, suffixes after the last - are stripped one at a time and every shortened variant is also tried (for example RE1000-2-1 → RE1000-2 → RE1000). Only invoice numbers that actually exist are used.
  2. Separator: if Separator is not ; and not empty, every occurrence of it in TrackingID is replaced by ;. Internally ; is always used as the delimiter.
  3. If no invoice is found, the row InvoiceNR is not existing is returned and nothing is changed.
  4. If the invoice is found, the row InvoiceNR found and Updated is returned first. Then:
    • Overwrite = 1: Invoices.ShipmentTrackingID is cleared. All packages of the invoice that have no package lines are detached from InvoicePolling (InvoicePackageId set to NULL). Packages without package lines are deleted, except the package with the lowest Id.
    • The internal procedure Pixi_SetTrackingId is executed. It splits the tracking IDs, ignores IDs already stored on the invoice and distributes the new IDs to packages:
      • If no package has package lines from a packing station, a single existing package with an empty tracking ID receives the first new ID. All other new IDs, or all new IDs if no such package exists, are inserted as new packages. ShipmentTrackingID on the invoice is then rebuilt from all distinct package tracking IDs, sorted and separated by ;.
      • If packages with package lines exist and there is exactly one package, that package receives the last new ID. If there are several packages, the packages are left unchanged. ShipmentTrackingID becomes the union of the existing and the new IDs.
      • Invoices.Packages is set to the number of packages, and UpdateDate and UpdateEmp (TrackingID Import) are updated. An InvoiceChanged event is published.
    • ResetClientNotifiedFlag = 1: for all order lines on the invoice, the most recent OrderHistory entry with status AUS gets ClientNotified = 'N'. The shipment is then reported to the client or shop again with the tracking ID.

Notes

  • The procedure runs in its own transaction, or in a savepoint if a transaction is already open.
  • Errors are swallowed: they are caught, the transaction is rolled back and the error is logged via log.InsertError. No error is raised to the caller. Because the message InvoiceNR found and Updated is selected before the changes are made, it can be returned even though all changes were rolled back.
  • Invoice number resolution: if several variants match (e.g. RE1000-1 and RE1000), the result of the ordered variable assignment typically picks the shortest matching number. Pass the exact invoice number to avoid ambiguity.
  • Overwrite does not reset the tracking ID of the package that is kept (lowest Id). If that package already has a tracking ID, the new IDs are added as additional packages, and the old ID reappears in ShipmentTrackingID, which is rebuilt from all packages.
  • Overwrite detaches InvoicePolling rows also from the kept package if it has no package lines.
  • Packages with package lines are never deleted. If several such packages exist, package tracking IDs are not changed at all; only the invoice field is extended. The internal procedure itself warns that tracking IDs should preferably be set per package.
  • Tracking IDs are truncated to 512 characters each. Splitting is done by dbo.fPixi_GetCommaSplit, the user lookup by inf.UserGetByName and event publishing by dbo.Pixi_MQ_EventPublish. Their definitions are not attached.
  • Lookups use NOLOCK; updates use ROWLOCK.

Tables used

Invoices · Write InvoicePackage · Write InvoicePackageLines · Read InvoicePolling · Write OrderHistory · Write Invlines · Read
SQL object:
dbo.pipiInvoiceSetTrackingID
Updated at 2026-10-30