pixiUpdateSupplierOrder
Updates status, note for the supplier, external order number and estimated delivery date of a supplier order identified by its internal number.
Changes a supplier order (purchase order to a Lieferant) that is identified by SupplierOrderNR (the order's InternalNumber).
Steps
- Empty strings in
StatusandSupplierOrderNRExtdrnaland an emptyNoteare treated asNULL(not passed). UserNamemust exist in the Pixi user table; otherwise anERRORrow is returned and an SQL error is raised.- The order and its current status are loaded. If
Statusis not passed, the current status code of the order is used. - Validation (each failure returns an
ERRORrow, nothing is changed):- the order must exist;
Statusmust beNEW,BES,CONorCLS;- a closed order (
CLS) accepts no newEstimatedDeliveryDateand no newSupplierOrderNRExtdrnal; - a confirmed order (
CON) accepts no newSupplierOrderNRExtdrnal; - no backward change from
CLStoNEW/BES/CONand fromCONtoNEW(CON→BESis allowed); - no skipping:
NEWcannot go directly toCONorCLS, andBEScannot go directly toCLS.
- The order header is updated:
- status is set (
NEW=1,BES=2,CON=3,CLS=4); - with
BESthe order date and ordering user are set to now/the calling user, withCONthe confirmation date and confirming user; - external code, note for the supplier and estimated delivery date are only overwritten when a value is passed;
- modification user and timestamp are set.
- status is set (
- If
EstimatedDeliveryDateis passed, it is also written to all lines of the supplier order. - If the status actually changed, the event
SupplierOrderStatusChangedis published with the internal orderId. - A single row with
ReturnCode=Okis returned and the transaction is committed.
Notes
- Pitfall – dates are reset: because an omitted
Statusfalls back to the current status, every call on an order in statusBESsetsOrderDate/OrderedByUserIdagain to now and the calling user; on an order inCONthe same happens toConfirmationDate/ConfirmedByUserId. This also applies when only the note or the delivery date is changed. - Fields cannot be cleared: an empty or omitted value keeps the stored value. An
EstimatedDeliveryDateof1900-01-01is treated as not passed. - The note is still accepted on closed orders; only delivery date and external number are blocked.
- The code comment says
NEWcannot be set again, but the code only blocksNEWfromCON/CLS; a changeBES→NEWis accepted. SupplierOrderNRExtdrnalis limited to 25 characters by the parameter type. The note is stored in a non-Unicode column, so characters outside the database code page may be lost.- Status IDs 1–4 are hard-coded in the procedure.
- Because of operator precedence in the validation, a backward/skip status error can override an earlier validation message; the call still fails in either case.
- Runs in its own transaction (or a savepoint if an outer transaction exists). Errors are caught, rolled back and written to the error log; except for the user check, no SQL error is raised, only the
ERRORrow is returned. When called inside an outer transaction, noOkrow is returned and no commit is done. - The initial lookup of the order reads with
NOLOCK. - The status change event is published via
Pixi_MQ_EventPublish; whether a message is actually sent depends on the settingpixiMQ_Enabledand the event configuration.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
SupplierOrderNR
Required
|
int | – |
Internal number ( Example: |
Status
|
varchar(3) string |
NULL |
New status code. If omitted or empty, the current status is kept (and re-applied). Allowed values
Example: |
Note
|
text string |
NULL |
Note for the supplier ( Example: |
EstimatedDeliveryDate
|
datetime dateTime |
NULL |
Estimated delivery date; written to the order header and to all order lines. Not allowed on closed orders. Example: |
SupplierOrderNRExtdrnal
|
varchar(25) string |
NULL |
External order number of the supplier ( Example: |
UserName
|
varchar(50) string |
API |
Pixi user name recorded as modifying (and ordering/confirming) user. Must exist. Example: |
Result set 1 · Always one row: Ok on success (outside an outer transaction), ERROR on any failure.
Status row of the update.
| Column | Type | Description |
|---|---|---|
ReturnCode
|
varchar(5) string |
|
ErrorMessage
Nullable |
nvarchar(4000) string |
Success text or error message. |
Response example
<SqlRowSet1>
<row>
<ReturnCode>Ok</ReturnCode>
<ErrorMessage>Supplier Order with SupplierOrderNR 10234 updated.</ErrorMessage>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| ERROR | User for create employee does not exist. | `UserName` does not exist in Pixi. Additionally raised as SQL error (severity 16). Pass an existing user name. |
| ERROR | Supplierorder with SupplierOrderNR {SupplierOrderNR} does not exist. | No supplier order with this internal number exists. |
| ERROR | Status can only be NEW, BES, CON or CLS | `Status` contains an unsupported code. |
| ERROR | Status of Order is CLS, no more changes possible. | The order is closed and `EstimatedDeliveryDate` or `SupplierOrderNRExtdrnal` was passed. |
| ERROR | Status of Order is CON, no change of ExternalCode possible. | The order is confirmed and `SupplierOrderNRExtdrnal` was passed. |
| ERROR | Status can not be changed back to {Status}. | Backward status change: from CLS to NEW/BES/CON, or from CON to NEW. |
| ERROR | Status can not be changed to {Status} if current status is {NEW.|BES|unknown}. | A status was skipped: NEW to CON/CLS or BES to CLS. Move through the statuses step by step (NEW → BES → CON → CLS). |
| ERROR | {SQL error message} | Any other SQL error during the update; the transaction is rolled back and the error is logged. |
POST https://apigateway.descartes.com/tms/pixi/
Content-Type: text/xml; charset=utf-8
Authorization: Basic BASE64(USERNAME:PASSWORD)
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://apigateway.descartes.com/tms/pixi/">
<SOAP-ENV:Body>
<ns1:pixiUpdateSupplierOrder>
<SupplierOrderNR>10234</SupplierOrderNR>
<!-- <Status>BES</Status> -->
<!-- <Note>Please deliver on euro pallets.</Note> -->
<!-- <EstimatedDeliveryDate>2024-06-15T00:00:00</EstimatedDeliveryDate> -->
<!-- <SupplierOrderNRExtdrnal>AB-2024-0815</SupplierOrderNRExtdrnal> -->
<!-- <UserName>API</UserName> -->
</ns1:pixiUpdateSupplierOrder>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
curl -X POST 'https://apigateway.descartes.com/tms/pixi/' \
--user 'USERNAME:PASSWORD' \
--header 'Content-Type: text/xml; charset=utf-8' \
--data-binary @- <<'XML'
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://apigateway.descartes.com/tms/pixi/">
<SOAP-ENV:Body>
<ns1:pixiUpdateSupplierOrder>
<SupplierOrderNR>10234</SupplierOrderNR>
<!-- <Status>BES</Status> -->
<!-- <Note>Please deliver on euro pallets.</Note> -->
<!-- <EstimatedDeliveryDate>2024-06-15T00:00:00</EstimatedDeliveryDate> -->
<!-- <SupplierOrderNRExtdrnal>AB-2024-0815</SupplierOrderNRExtdrnal> -->
<!-- <UserName>API</UserName> -->
</ns1:pixiUpdateSupplierOrder>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
XML
<?php
$soapClient = new SoapClient(null, [
'login' => 'USERNAME',
'password' => 'PASSWORD',
'location' => 'https://apigateway.descartes.com/tms/pixi/',
'uri' => 'https://apigateway.descartes.com/tms/pixi/',
]);
$arguments = [
'SupplierOrderNR' => '10234',
// 'Status' => 'BES',
// 'Note' => 'Please deliver on euro pallets.',
// 'EstimatedDeliveryDate' => '2024-06-15T00:00:00',
// 'SupplierOrderNRExtdrnal' => 'AB-2024-0815',
// 'UserName' => 'API',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiUpdateSupplierOrder', $soapArguments);
- SQL object:
- dbo.pipiUpdateSupplierOrder