Rackbeat - Create/Update Customer
This document describes the process of creating and updating customers in Rackbeat from App4Sales.
Trigger & Permissions
The creation and update of customers are triggered when a user in the App4Sales application initiates the creation of a new customer or edits an existing one. This functionality is enabled when the connector is configured with the CreateCustomer or EditCustomer flags.
Duplicate Detection & Existing Customers
The connector checks if a CustomerCode is present on the App4Sales Customer object. If the CustomerCode is null or empty, the connector assumes it's a new customer and proceeds with the creation process. If a CustomerCode exists, the connector updates the existing customer in Rackbeat.
Payload Mapping
The connector maps the App4Sales Customer object to the Rackbeat API's format. The main customer data, addresses, and contacts are sent in separate API calls.
Customer
The customer data is sent via an HTTP POST (for creation) or PUT (for update) request to /api/customers.
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
CompanyName | Customer.CustomerName | Mapped directly. |
Locale | Customer.LanguageCode | Mapped directly. |
Ean | Customer.ChamberOfCommerceCode | Mapped directly. |
ContactEmail | Customer.Email | Mapped directly. |
ContactPhone | Customer.Phone | Mapped directly. |
PaymentTermsId | Customer.UnknownElements["PaymentTerms"] | The value is retrieved from the customer's "UnknownElements" dictionary with the key "PaymentTerms". |
VatZone | Customer.UnknownElements["VatZone"] | The value is retrieved from the customer's "UnknownElements" dictionary with the key "VatZone". |
LayoutId | Customer.UnknownElements["Layout"] | The value is retrieved from the customer's "UnknownElements" dictionary with the key "Layout". |
CustomerGroupId | Customer.UnknownElements["CustomerGroup"] | The value is retrieved from the customer's "UnknownElements" dictionary with the key "CustomerGroup". |
GeneralDiscountPercentage | Customer.Discount | Mapped directly. Defaults to 0 if null. |
Currency | Customer.UnknownElements["Currency"] | The value is retrieved from the customer's "UnknownElements" dictionary with the key "Currency". |
Street | Visit Address.AddressLine1 | From the first address with type 'Visit'. |
Street2 | Visit Address.AddressLine2 | From the first address with type 'Visit'. |
City | Visit Address.City | From the first address with type 'Visit'. |
Country | Visit Address.Country | From the first address with type 'Visit'. |
Zipcode | Visit Address.PostCode | From the first address with type 'Visit'. |
State | Visit Address.State | From the first address with type 'Visit'. |
DeliveryAddress | Delivery Address | The first address with type 'Delivery' is mapped to the delivery address. See Address mapping below. |
Contact
The contact person is sent via an HTTP POST to /api/customers/{customer_code}/contacts.
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
ContactPerson.Email | Mapped directly. | |
Phone | ContactPerson.Phonenumber | Mapped directly. |
Name | ContactPerson.FullName | Mapped directly. |
Address
Addresses are sent via an HTTP POST to /api/customers/{customer_code}/addresses.
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
Street | Address.AddressLine1 | Mapped directly. |
Street2 | Address.AddressLine2 | Mapped directly. |
Zipcode | Address.PostCode | Mapped directly. |
City | Address.City | Mapped directly. |
Country | Address.Country | Mapped directly. |
State | Address.State | Mapped directly. |
Type | Address.AddressType | If the App4Sales address type is 'Delivery', it is mapped to 'delivery'. If it is 'Visit', it is mapped to 'billing'. Otherwise, it is mapped to 'any'. |
Validation & Defaults
The connector relies on the data provided by App4Sales. There is no specific validation or default logic in the connector itself, other than the discount defaulting to 0 if not provided.
Response & Error Handling
After a successful customer creation, Rackbeat returns the new customer number, which is then stored in the CustomerCode field of the App4Sales Customer object. If the API call fails, an exception is thrown with the error message from Rackbeat, and this is logged.