Postman collection
Invoices Write

pixiUpdateInvoicePackageTrackingIds

Sets the shipment and return tracking IDs of an invoice and, where it can be identified, of its invoice package, and publishes an `InvoiceChanged` event.

Updates tracking information on a Rechnung (Invoices) and its package (pixi.InvoicePackage). The result is always one status row with Status and Message.

Validation

  • At least one of PackageId or InvoiceNr and at least one of TrackingId or ReturnTrackingId must be filled. Otherwise status 400 is returned. A PackageId of 0 counts as empty.
  • One leading and one trailing ; is removed from TrackingId and ReturnTrackingId.

Finding invoice and package

  • With InvoiceNr, the invoice is read by its number. All packages with Id = PackageId or belonging to that invoice are loaded.
  • With only PackageId, the package is loaded and its invoice is read.
  • If only InvoiceNr is sent, the invoice has more than one package and Overwrite = 1, status 400 is returned (PackageId is required).
  • If no package is found, status 400 is returned. This also happens when the invoice does not exist or has no package. The same applies if PackageId and InvoiceNr are both sent but the package does not belong to the invoice.
  • If the combined length of the stored value and the new value exceeds 512 characters, status 411 is returned. This is checked for ShipmentTrackingID and for retTrackIDhist.

Which records are updated

  • The invoice is always updated.
  • The package is also updated in three cases:
    • PackageId and InvoiceNr match.
    • Only InvoiceNr is sent and the invoice has exactly one package.
    • Only PackageId is sent.
  • If only InvoiceNr is sent, the invoice has several packages and Overwrite = 0, only the invoice is updated.

Shipment tracking (TrackingId)

  • Overwrite = 0: TrackingId is appended to Invoices.ShipmentTrackingID, separated by ;. This only happens if the existing value does not already contain it (substring match).
  • Overwrite = 1: ShipmentTrackingID is rebuilt from the tracking IDs of all other packages of the invoice, each followed by ;, plus TrackingId. If TrackingId is already contained in the sibling list, ShipmentTrackingID becomes TrackingId alone.
  • The package gets only the last ;-separated segment of TrackingId as its TrackingID.

Return tracking (ReturnTrackingId)

  • Overwrite does not affect return tracking.
  • If ReturnTrackingId is not yet contained in Invoices.retTrackID:
    • retTrackID is set to its last ;-separated segment.
    • The full value plus a trailing ; is appended to retTrackIDhist.
  • The package gets the last segment as its ReturnTrackingId.

Further steps

  • The invoice gets UpdateDate = GETDATE() and UpdateEmp = '(Return) TrackingID API Update'.
  • The package gets RecordModifiedOn and RecordModifiedByUserId, the ID of the user API.
  • With ResetClientNotifiedFlag = 1, ClientNotified is set to N on the latest AUS (shipped) OrderHistory entry of each order line on the invoice. The shipment is then exported or notified again.
  • Finally the MQ event InvoiceChanged is published with the invoice key and the parameter SetTrackingId.

Notes

  • Transaction: all changes run in one transaction. A savepoint is used if the caller already has an open transaction. Validation errors (400/411) change nothing; the transaction is still committed and the status row is returned.
  • Unexpected SQL errors: the transaction is rolled back and the error is written via log.InsertError. No status row is returned in this case.
  • Status as string: Status is a string (200, 400, 411), not an HTTP status. The SOAP call itself succeeds.
  • Duplicate check: the check for an existing tracking ID is a LIKE '%…%' substring match. A new ID that is part of an existing longer ID, or that contains % / _, may wrongly be treated as already present and not be appended.
  • Messages: they mention InvoiceKey, but the parameter is PackageId.
  • NOLOCK: invoices and packages are read with NOLOCK.
  • Triggers: CONTEXT_INFO is set to 0x11111 during the invoice update, presumably so that triggers can recognise this update. Their behaviour is not visible here.
  • Unknown API user: if no user API exists in UCS_USERS, RecordModifiedByUserId is set to NULL.
  • MQ event: InvoiceChanged is only sent if the setting pixiMQ_Enabled is active and the event is configured and enabled in EventConfiguration. Delivery failures are queued in EventQueue and do not cause an error in this call.

Tables used

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