BjornLunden - Create/Update Customer
This document describes the process of creating and updating customers in the Bjorn Lunden ERP system from App4Sales. The connector supports both creating new customers and updating existing ones based on whether a `CustomerCode` is present.
Trigger & Permissions
The customer creation/update process is triggered when a user with the appropriate permissions creates or edits a customer in the App4Sales app. The connector must have the CreateCustomer and/or EditCustomer features enabled in the connector information settings.
Data Source Configuration
The connector interacts with the Bjorn Lunden REST API. The base URL and authentication details are configured in the connector settings. The specific endpoints for customer operations are constructed dynamically by the `BLRouteBuilder`.
Payload Mapping
The following tables detail the mapping from App4Sales customer fields to the Bjorn Lunden `customer` API object.
Customer Header
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
Name | CustomerName | Direct mapping. |
MainContactPerson.Email or Customer.Email | Uses the main contact person's email if available, otherwise falls back to the customer's email. | |
Phone | Phone | Direct mapping. |
NoVat | VatLiable | Inverted boolean mapping. `NoVat` is true if `VatLiable` is false. |
Pricelist | UsesPriceField | Direct mapping. |
VatNumber | VatCode | Direct mapping. |
VatCode | VatCode | Direct mapping. |
Fax | Fax | Direct mapping. |
Mobile | MainContactPerson.MobileNumber | Direct mapping. |
ResponsiblePerson | MainContactPerson.FullName | Direct mapping. |
Addresses
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
City | Addresses (Visit) | From the main visit address. |
Country | Addresses (Visit) | From the main visit address. |
CountryCode | Addresses (Visit) | From the main visit address. |
VisitAddressLine | Addresses (Visit) | AddressLine1 from the main visit address. |
PostAddressLine | Addresses (Invoice) | AddressLine1 from the main invoice address. |
Zip | Addresses (Invoice) | PostCode from the main invoice address. |
Validation & Defaults
The connector relies on the data provided from App4Sales. There is no specific validation or default logic in the connector itself, beyond the standard data type conversions. The update operation requires a valid integer `InternalCode` to identify the customer in Bjorn Lunden.
Response & Error Handling
The ERP response is parsed, and the newly created or updated customer data is returned to App4Sales. If an error occurs during the API call, an exception is thrown and logged. For updates, if the `InternalCode` is not a valid integer, an error is logged and an exception is thrown.
Related Settings & Prerequisites
The following settings in the `BjornLunden` connector configuration are relevant for this process:
CustomCustomerFieldsMapping: A JSON mapping to handle dynamic free fields. If configured, the connector will map `ExtraFieldValues` from App4Sales to the corresponding fields in the Bjorn Lunden customer object.