ExactOnlinePremium Connector - Create Customer
This document describes the customer creation and update process within the ExactOnlinePremium connector. This function handles incoming customer data from App4Sales, transforms it into an Exact Online customer entity, and either creates a new customer or updates an existing one in Exact Online. It also manages associated contact persons and addresses.
3. Data Source Configuration
The customer data originates from an InternalRequest object. This object encapsulates the incoming payload from App4Sales, typically containing customer information in an XML format. The connector extracts customer entities from this request using the XMLParserObj.GetCustomersFromRequest(request) method.
Trigger & Permissions
This customer creation/update process is triggered when a new customer is created or an existing customer is edited within the App4Sales platform. The functionality is enabled by the following connector info flags:
Core.Constants.ConnectorInfoInternalIds.EditCustomerCore.Constants.ConnectorInfoInternalIds.CreateCustomer
Payload Mapping
The connector transforms the incoming XmlCustomer object (parsed from the App4Sales request) into an ExactOnlineCustomerUpdate entity. The following table details the mapping of fields:
App4Sales Field (XmlCustomer) | Source Field (ExactOnlineCustomerUpdate) | Logic/Notes |
|
| Direct mapping. |
|
| Direct mapping. |
|
| If |
- |
| Hardcoded to |
|
| Direct mapping. |
|
| If |
|
| Direct mapping. |
|
| Direct mapping. |
- |
| Hardcoded to |
- |
| Maps to |
|
| If present, converted to uppercase. |
|
| If |
|
| Direct mapping. |
|
| If |
|
| Mapped to |
|
| Determined by the |
- |
| Hardcoded to |
|
| Direct mapping. |
|
| Direct mapping. |
|
| Direct mapping. |
|
| Direct mapping. |
|
| Direct mapping. |
|
| Determined by |
|
| Determined by |
|
| Passed as a parameter to the |
- |
| Hardcoded to |
- |
| Hardcoded to |
|
| Mapped to |
|
| Mapped to |
|
| Direct mapping. |
- |
| Hardcoded to |
- |
| Hardcoded to |
Custom Fields
Additional custom fields can be mapped from the XmlCustomer.UnknownElements to the ExactOnlineCustomerUpdate entity based on the settings.CustomCustomerFieldsMapping. Each entry in CustomCustomerFieldsMapping specifies an XmlName and a PropertyName. If an element with the XmlName exists in XmlCustomer.UnknownElements and the object name is 'customer', its value is added to restRequest.AddUnknownElement with the specified PropertyName.
Validation & Defaults
GL Account Sales: The
GLAccountSalesfield in Exact Online is populated from the connector settingSettings.GLAccountSalesCode.GLAR (Accounts Receivable): The
GLARfield in Exact Online is populated from the connector settingSettings.GLAccountGLARCode.Price List ID: The
priceListIdis determined by parsing theUsesPricefield from the incomingXmlCustomer. IfUsesPriceis '2', '3', or '4', the corresponding PriceList ID (PriceList2Id,PriceList3Id, orPriceList4Id) from the connector settings is used. If parsing fails or the value is not '2', '3', or '4', it defaults toGuid.Empty.Currency: The
SalesCurrencyis determined by a passedcurrencyparameter or derived from theUsesPricefield usingPriceListsContext.Instance.GetCurrencyByPriceListId.
Response & Error Handling
After attempting to create or update a customer in Exact Online, the connector processes the response as follows:
Successful Creation: If a new customer is successfully created, Exact Online returns a customer code. This code is then used to update the corresponding customer entry in the App4Sales database. Duplicate customer codes in the App4Sales database are handled by prefixing the existing code with "D" before updating.
Successful Update: If an existing customer is successfully updated, the connector confirms the update and uses the existing customer code.
REST API Errors (
RestException): If the Exact Online API returns an error, aRestExceptionis caught. The error response content is deserialized to extract a user-friendly error message, which is then logged and returned to App4Sales, prefixed withERROR:.
Special Logic & Filters
Upsert Logic: The connector intelligently handles customer creation and updates. If the incoming
XmlCustomerobject has an emptyCustomerCode, it is treated as a new customer and aPOSTrequest is made to Exact Online. If aCustomerCodeis present, it's considered an existing customer, and aPUTrequest is issued to update the existing record.Duplicate Customer Code Handling: When a new customer is created, and the assigned customer code from Exact Online already exists in the App4Sales database, the existing App4Sales customer's code is prefixed with "D" to avoid conflicts, ensuring Exact Online remains the leading system for customer codes.
Contact Person Management: After processing the main customer entity, the connector attempts to create or update the main contact person associated with the customer.
It first checks for an existing contact person ID in the App4Sales database.
If no ID is found, a new GUID is generated, the
XmlCustomeris converted to anExactOnlineContactPersonUpdate, and aPOSTrequest is made to Exact Online. Custom fields withObjectName'contact' are also applied. The newly obtained Exact Online contact ID is then stored in the App4Sales database.If a contact ID exists, the
XmlCustomeris converted, custom fields are applied, and aPUTrequest is used to update the existing contact person in Exact Online.
Delivery Address Management: The connector also manages the customer's delivery address.
If both
DeliveryAddress1andDeliveryPostCodeare empty in the incomingXmlCustomer, no delivery address processing occurs.It checks for an existing main delivery address in Exact Online for the customer.
The
XmlCustomerdata is converted into anExactOnlineAddressUpdateobject, and custom fields withObjectName'address' are applied.Based on whether an existing address was found, a
POST(new) orPUT(update) request is made to Exact Online. The address ID in App4Sales is then updated.
Invoice Address Management: If the incoming
XmlCustomercontains invoice address information (checked viac.UnknownElements.ContainsKey(Constants.InvoiceAddress1)),The connector first checks if a main invoice address already exists in Exact Online for the customer.
The
XmlCustomerdata is converted into anExactOnlineAddressUpdatespecifically for the invoice address. If no invoice address data is available for conversion, this step is skipped.Similar to delivery addresses, a
POSTorPUTrequest is made to Exact Online to create or update the invoice address.
Custom Fields
Additional custom fields can be mapped from the XmlCustomer.UnknownElements to the ExactOnlineCustomerUpdate entity based on the settings.CustomCustomerFieldsMapping. Each entry in CustomCustomerFieldsMapping specifies an XmlName and a PropertyName. If an element with the XmlName exists in XmlCustomer.UnknownElements and the object name is 'customer', its value is added to restRequest.AddUnknownElement with the specified PropertyName.
Related Settings & Prerequisites
The behavior of the customer creation/update process is influenced by the following connector settings:
CustomCustomerFieldsMapping: Defines how custom fields from the incoming App4Sales request (XmlCustomer.UnknownElements) are mapped to the Exact Online customer, contact person, and address entities.GenerateCurrencyPriceLists: (Boolean) If enabled, the connector attempts to determine the customer's currency based on their price list.GLAccountSalesCode: Specifies the GL Account for Sales to be used for new or updated customers in Exact Online.GLAccountGLARCode: Specifies the GLAR (General Ledger Accounts Receivable) to be used for new or updated customers in Exact Online.OnlyLoadDealers: (Boolean) If enabled, new customers are marked as resellers in Exact Online.VatLiabilityBasedOnVatRegime: (Boolean) If enabled, the VAT Liability in Exact Online is set to 'L' (Liable) based on the customer'sVatLiablestatus.PriceList2Id,PriceList3Id,PriceList4Id: GUIDs for specific price lists in Exact Online. These are used when the incoming customer'sUsesPricefield corresponds to '2', '3', or '4' respectively, to assign the correct price list to the customer.VatCodeBasedOnCountryCode: Specifies a country code. Used in conjunction withUseVatLiabilityForDefaultCountryto determine the Sales VAT Code.UseVatLiabilityForDefaultCountry: (Boolean) If enabled, and the customer's country matchesVatCodeBasedOnCountryCode, thenVatLiableCodeis used as the Sales VAT Code. Otherwise,NotVatLiableCodeorNotVatLiableCodeOutsideEUis used.VatLiableCode: The VAT code to use when the customer is VAT liable, or whenUseVatLiabilityForDefaultCountryis enabled and the country matchesVatCodeBasedOnCountryCode.NotVatLiableCode: The VAT code to use when the customer is not VAT liable and is within the EU.NotVatLiableCodeOutsideEU: The VAT code to use when the customer is not VAT liable and is outside the EU. If empty,NotVatLiableCodeis used as a fallback.UpdateEmailOnlyForCustomer: (Boolean) If enabled, email addresses are not updated for contact persons or delivery addresses.UpdatePhoneOnlyForCustomer: (Boolean) If enabled, phone numbers are not updated for contact persons or delivery addresses.SendHouseNumberAndAdditionSeperate: (Boolean) If enabled, the street, house number, and addition from an address are sent as separate fields (AddressLine1, AddressLine2, AddressLine3) to Exact Online.