pixiUpdateCustomer
Updates the e-mail, name and postal address of an existing customer and its linked address, saving the previous address to the address history.
Updates a customer identified by CustKey together with the address linked to it through Customers.AddrRef.
- All text parameters are trimmed. Empty strings are treated as
NULL. - The customer is looked up by
CustKey, joined to its address. The customer must have a linked address.- No match: status
404. - More than one match: status
409.
- No match: status
- If exactly one customer is found, the following steps run in one transaction:
- The current address is copied to the address history.
HUpdateEmpis set toAPIandHNoteHisttoDuplicate Check App. - The customer's e-mail (
Customers.CeMail) is set toeMail. This is always done, even ifeMailisNULL. - The address is updated. Only parameters that are not
NULLchange the stored value:FirstName,LastName,Street,HouseNr,City,ZIPandeMailare updated individually.Nameis rebuilt as first name + space + last name.Addressis rebuilt as street + space + house number.
- The call returns status
200.
- The current address is copied to the address history.
- Any SQL error rolls back the transaction and returns status
500with the SQL error text.
The call always returns exactly one status row with StatusCode and ErrorMsg. ErrorMsg also holds the success message.
Notes
- Pitfall – customer e-mail is cleared:
Customers.CeMailis overwritten witheMailwithout aNULLcheck. Leaving outeMail, or passing an empty value, clears the customer's e-mail. Only the address e-mail (Addresses.eMail) keeps its old value. Always pass the current e-mail if it must not change. - Pitfall – rebuilt fields:
NameandAddressare always rebuilt from first/last name and street/house number. The rebuild uses the parameters, or the stored column values if a parameter isNULL. If one of the two parts isNULLin both the parameter and the stored column, the result is usuallyNULL(standardCONCAT_NULL_YIELDS_NULLbehaviour). A manually maintained value inNameorAddressis overwritten. - Not written to history: the history row stores only the classic address fields (for example
Name,Address,City,ZIP).FirstName,LastName,Street,HouseNrandeMailare not saved there. - Context info: during the address update the session
CONTEXT_INFOis set to0x33999and reset to0x00000afterwards. Its purpose is not visible in the code; it is probably evaluated by triggers onAddresses. - Locking: the lookup reads with
NOLOCK. The updates useROWLOCKinside the named transactionUpdateCustomer. - Error handling: the CATCH block always issues
ROLLBACK TRANSACTION. If an error occurs before the transaction has started, this rollback may raise an additional SQL error, which arrives as aSqlMessagealongside the500status row. - Cleanup: the temporary table is dropped via
util.TempTableDrop. Its definition is not attached. - NULL key: if
CustKeyisNULL, status404is returned andErrorMsgisNULL.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
CustKey
Required
|
int | – |
Key of the customer to update. Example: |
Street
|
varchar(255) string |
NULL |
New street. Trimmed; empty or Example: |
HouseNr
|
varchar(10) string |
NULL |
New house number. Trimmed; empty or Example: |
City
|
varchar(60) string |
NULL |
New city. Trimmed; empty or Example: |
Zip
|
varchar(10) string |
NULL |
New postal code. Trimmed; empty or Example: |
eMail
|
varchar(256) string |
NULL |
New e-mail address. Trimmed. Always written to Example: |
FirstName
|
varchar(60) string |
NULL |
New first name. Trimmed; empty or Example: |
LastName
|
varchar(60) string |
NULL |
New last name. Trimmed; empty or Example: |
Result set 1 · Always
Status row with an HTTP-like status code and a message (success or error text).
| Column | Type | Description |
|---|---|---|
StatusCode
|
varchar(10) string |
|
ErrorMsg
Nullable |
varchar(4000) string |
Message text; also contains the success message for status |
Response example
<SqlRowSet1>
<row>
<StatusCode>200</StatusCode>
<ErrorMsg>Customer with CustKey: 12345 was updated.</ErrorMsg>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| 404 | Customer with CustKey: {CustKey} does not exist. | No customer with this `CustKey` exists, or the customer has no linked address (`AddrRef`). Check the key. |
| 409 | Customer with CustKey: {CustKey} could not be uniquely identified. {RowCount} customers found. | The lookup of customer and address returned more than one row. Nothing is updated. |
| 500 | {ERROR_MESSAGE()} | A SQL error occurred, for example a constraint or trigger error. The transaction is rolled back and the SQL error text is returned. |
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:pixiUpdateCustomer>
<CustKey>12345</CustKey>
<!-- <Street>Hauptstraße</Street> -->
<!-- <HouseNr>12a</HouseNr> -->
<!-- <City>München</City> -->
<!-- <Zip>80331</Zip> -->
<!-- <eMail>max.mustermann@example.com</eMail> -->
<!-- <FirstName>Max</FirstName> -->
<!-- <LastName>Mustermann</LastName> -->
</ns1:pixiUpdateCustomer>
</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:pixiUpdateCustomer>
<CustKey>12345</CustKey>
<!-- <Street>Hauptstraße</Street> -->
<!-- <HouseNr>12a</HouseNr> -->
<!-- <City>München</City> -->
<!-- <Zip>80331</Zip> -->
<!-- <eMail>max.mustermann@example.com</eMail> -->
<!-- <FirstName>Max</FirstName> -->
<!-- <LastName>Mustermann</LastName> -->
</ns1:pixiUpdateCustomer>
</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 = [
'CustKey' => '12345',
// 'Street' => 'Hauptstraße',
// 'HouseNr' => '12a',
// 'City' => 'München',
// 'Zip' => '80331',
// 'eMail' => 'max.mustermann@example.com',
// 'FirstName' => 'Max',
// 'LastName' => 'Mustermann',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiUpdateCustomer', $soapArguments);
- SQL object:
- dbo.pipiUpdateCustomer