ExactOnlineV2 - Create Customer
This function creates or updates a customer in Exact Online. The process is triggered when a new customer is created in the App4Sales application. It handles the mapping of customer data, including addresses and contact persons, to the corresponding entities in Exact Online.
Trigger & Permissions
This functionality is enabled when the connector settings `CreateCustomer` or `EditCustomer` are active. The creation process is initiated from the App4Sales application.
Payload Mapping
The following tables describe the mapping of fields from the App4Sales `Customer` object to the Exact Online `Account` object.
Customer
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
ID | CustomerGuid | The unique identifier of the customer. |
Name | CustomerName | The name of the customer. |
Code | CustomerCode | The customer code. If empty, a new customer is created. Otherwise, the existing customer with this code is updated. |
Blocked | N/A | Hardcoded to `false`. |
ChamberOfCommerce | ChamberOfCommerceCode | The Chamber of Commerce registration number. |
DiscountSales | Discount | The customer's discount percentage, divided by 100. For example, a 10% discount is sent as `0.1`. |
The customer's email address. | ||
Fax | Fax | The customer's fax number. |
IsSales | N/A | Hardcoded to `true`. |
IsReseller | OnlyLoadDealers (Setting) | Value is based on the `OnlyLoadDealers` setting. |
Language | LanguageCode | The customer's language code, converted to uppercase. |
PaymentConditionSales | PaymentCondition | The customer's payment condition. |
Phone | Phone | The customer's phone number. |
VATNumber | VatCode | The customer's VAT number. |
VATLiability | VatLiable, VatLiabilityBasedOnVatRegime (Setting) | Set to "L" if `VatLiable` is true and `VatLiabilityBasedOnVatRegime` setting is enabled. Otherwise, it's `null`. |
SalesVATCode | VatLiable, CountryCode, VatLiableCode (Setting), NotVatLiableCode (Setting), NotVatLiableCodeOutsideEU (Setting) | Determined based on the customer's VAT liability, country, and several connector settings. |
Status | N/A | Hardcoded to "C" (Customer). |
AddressLine1 | VisitAddress1 | The first line of the visiting address. |
AddressLine2 | VisitAddress2 | The second line of the visiting address. |
City | VisitCity | The city of the visiting address. |
Country | CountryCode | The country code of the visiting address. |
Postcode | VisitPostCode | The postal code of the visiting address. |
PriceList | UsesPrice, PriceList2Id (Setting), PriceList3Id (Setting), PriceList4Id (Setting) | The price list associated with the customer. Determined by the `UsesPrice` field and connector settings for pricelists. |
SalesCurrency | UsesPrice, GenerateCurrencyPriceLists (Setting) | The currency for sales, determined by the pricelist or the `GenerateCurrencyPriceLists` setting. |
MainContact | N/A | The main contact person for the customer. This is set in a separate step after the customer is created. |
AccountManager | SalesRep | The account manager for the customer, based on the `SalesRep` from the request. |
Website | N/A | Hardcoded to an empty string. |
StartDate | N/A | Set to the current date and time. |
GLAccountSales | GLAccountSalesCode (Setting) | The sales GL account, from connector settings. |
GLAR | GLAccountGLARCode (Setting) | The accounts receivable GL account, from connector settings. |
Contact Person
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
Account | CustomerGuid | The GUID of the customer to which the contact person belongs. |
Email, UpdateEmailOnlyForCustomer (Setting) | The contact person's email address. Not updated if `UpdateEmailOnlyForCustomer` setting is enabled. | |
Phone | Phone, UpdatePhoneOnlyForCustomer (Setting) | The contact person's phone number. Not updated if `UpdatePhoneOnlyForCustomer` setting is enabled. |
Mobile | Mobile | The contact person's mobile number. |
FullName | ContactFullName | The full name of the contact person. Defaults to "-" if empty. |
Language | LanguageCode | The contact person's language code. |
IsMainContact | N/A | Hardcoded to `true`. |
FirstName | ContactFullName | The first name, extracted from the `ContactFullName`. |
LastName | ContactFullName | The last name, extracted from the `ContactFullName`. |
Gender | N/A | Hardcoded to "O" (Other). |
Delivery Address
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
Account | CustomerGuid | The GUID of the customer to which the address belongs. |
Phone | Phone, UpdatePhoneOnlyForCustomer (Setting) | The phone number for the address. Not updated if `UpdatePhoneOnlyForCustomer` setting is enabled. |
Mailbox | Email, UpdateEmailOnlyForCustomer (Setting) | The email for the address. Not updated if `UpdateEmailOnlyForCustomer` setting is enabled. |
AddressLine1 | DeliveryAddress1 | The first line of the delivery address. |
AddressLine2 | DeliveryAddress2 | The second line of the delivery address. |
City | DeliveryCity | The city of the delivery address. |
Country | CountryCode | The country code of the delivery address. Defaults to "NL" if empty. |
Postcode | DeliveryPostCode | The postal code of the delivery address. |
Main | N/A | Hardcoded to `true`. |
Type | N/A | Hardcoded to `4` (Delivery address). |
Invoice Address
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
Account | CustomerGuid | The GUID of the customer to which the address belongs. |
AddressLine1 | InvoiceAddress1 (from UnknownElements) | The first line of the invoice address. |
AddressLine2 | InvoiceAddress2 (from UnknownElements) | The second line of the invoice address. |
AddressLine3 | InvoiceAddress3 (from UnknownElements) | The third line of the invoice address. |
City | InvoiceCity (from UnknownElements) | The city of the invoice address. |
Country | InvoiceCountry (from UnknownElements), CountryCode | The country code of the invoice address. Falls back to the customer's country code. |
Postcode | InvoicePostcode (from UnknownElements) | The postal code of the invoice address. |
Main | N/A | Hardcoded to `true`. |
Type | N/A | Hardcoded to `3` (Invoice address). |
Validation & Defaults
If `CustomerCode` is not provided, a new customer is created. Otherwise, the existing customer is updated.
If `ContactFullName` is empty, it defaults to "-".
The delivery address country defaults to "NL" if not provided.
The invoice address country falls back to the customer's main country if not provided.
Response & Error Handling
After a successful customer creation, the new Exact Online customer code is returned. This code is then saved in the App4Sales database. If an error occurs during the process (e.g., a `RestException` from the Exact Online API), a descriptive error message is returned to the user.
Related Settings & Prerequisites
CreateCustomer/EditCustomer: Must be enabled to allow customer creation/updates.CustomCustomerFieldsMapping: Allows for mapping of custom fields for customers, contacts, and addresses.GenerateCurrencyPriceLists: If enabled, the currency is determined based on the price list.GLAccountSalesCode: The GL account code for sales.GLAccountGLARCode: The GL account code for accounts receivable.PriceList2Id,PriceList3Id,PriceList4Id: GUIDs for different price lists.UpdateEmailOnlyForCustomer: If enabled, the email address of contact persons and addresses will not be updated.UpdatePhoneOnlyForCustomer: If enabled, the phone number of contact persons and addresses will not be updated.VatLiabilityBasedOnVatRegime: If enabled, `VatLiability` is set to "L" when `VatLiable` is true.VatLiableCode,NotVatLiableCode,NotVatLiableCodeOutsideEU: VAT codes used in the logic to determine the `SalesVATCode`.