NewBaseV4 Connector - CustomerUpdate
This document details the CustomerUpdate pipeline for the NewBaseV4 connector, explaining how customer data from the NewBaseV4 ERP system is synchronized and transformed into various App4Sales internal data models, including Customers, Addresses, Contact Persons, Item Class Value Discounts, and Dashboards. This process is crucial for maintaining up-to-date customer information within the App4Sales platform for Application Administrators and Implementation Consultants.
Data Source Configuration
The NewBaseV4 connector retrieves customer-related data primarily through its REST API. It fetches information about organisations, persons, contacts, account managers, and debtors from the NewBaseV4 system. Additional customer data can also be imported from CSV files. The connector pulls data from NewBaseV4 and pushes updates to the App4Sales internal database.
API Calls and Entities:
Organisations: Retrieved via
_organisationProvider.GetOrganisations().Persons: Retrieved via
NewBaseRepository<NewBasePerson>.Contacts: Retrieved via
_contactsProvider.GetContacts().Account Managers: Retrieved via
NewBaseRepository<NewBaseAccountManager>.Debtors: Retrieved via
NewBaseRepository<NewBaseDebtor>, filtered to include only those with a validCustomerCode.Notes: Retrieved via
NewBaseRepository<NewbaseNote>for existing notes, and inserted via API calls for new notes.Addresses: Retrieved as part of
NewBaseOrganisationdata.
The base URL and specific endpoints are defined in NewBaseV4Constants.Routes (e.g., https://webservice.newbase.nl/servoy-service/rest_ws/newbase_ws/).
Data Mapping Table
Customer Core Fields
This section details how core customer fields in App4Sales are populated from NewBaseV4.
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Directly mapped from the NewBaseV4 Debtor's customer code. If the |
|
| Directly mapped from the NewBaseV4 Debtor's name. If the |
|
| Set to |
|
| Directly mapped from the NewBaseV4 Debtor's VAT number. For USA administrations, this is always |
|
| Directly mapped from the NewBaseV4 Debtor's Chamber of Commerce registration. |
| Derived from customer's country and | Evaluated based on the customer's country. If the country code matches the |
|
| Mapped if |
|
| Directly mapped from the NewBaseV4 Debtor's creation date. Truncated to the second during processing. |
| System Timestamp | Truncated to the second during processing. |
|
| Mapped from NewBaseV4 Account Manager data, linked by |
|
| Directly mapped from the NewBaseV4 Debtor's language code. Further mapped using the |
|
| Resolved by |
|
| Directly mapped from the NewBaseV4 Debtor's currency. |
|
| Directly mapped from the NewBaseV4 Debtor's GUID. If the |
| (Derived from settings) | If |
| (N/A) | Set to |
| (Base64 encoded string from ERP) | The Base64 encoded string is decoded and stored as |
|
| If |
|
| Retrieved from NewBaseV4 Organisation's reachabilities for |
|
| Initially from NewBaseV4 Organisation's reachabilities (`ReachabilityType.Email`). If empty, it attempts to use the email from an associated NewBaseV4 Contact. Trimmed during processing. |
|
| Retrieved from NewBaseV4 Organisation's reachabilities for |
| Derived from | XML string containing
If |
|
| Populated by processing elements from |
| XML string (ERP source) | Deserialized from ERP source XML into |
(Various Customer properties) |
| Properties of the |
Addresses
Addresses are obtained from NewBaseOrganisation.Addresses and processed for App4Sales.
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Mapped to "VIS" (Visit), "DEL" (Delivery), or "INV" (Invoice). If |
|
| Directly mapped from the NewBaseV4 Address ID. |
|
| Directly mapped. |
|
| Directly mapped. |
|
| Directly mapped. |
|
| Directly mapped. |
|
| Derived from |
|
| Directly mapped. Trimmed and converted to lowercase for mapping with `mappedCountryCodes`. If empty, derived from |
|
| Retrieved from NewBaseV4 Organisation's reachabilities for |
|
| Initially from NewBaseV4 Organisation's reachabilities (`ReachabilityType.Email`). If empty, it attempts to use the email from an associated NewBaseV4 Contact. Trimmed during processing. If |
|
| Set to |
|
| Assigned from the parent customer's GUID. |
| Generated hash or ERP address id | If empty, a hash code is generated. Can also contain the ERP address ID. |
Contacts
Contact persons are obtained from NewBasePerson, NewBaseContact, and NewBaseOrganisation.
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Directly mapped. If the connector is in 'Updater' mode and |
|
| Directly mapped. If |
| Derived from | Parsed from |
|
| Directly mapped. If |
|
| Composed as |
|
| First character of |
|
| Initially from NewBaseV4 Contact's reachabilities (`ReachabilityType.Email`). If empty, it attempts to use the email from the associated NewBaseV4 Organisation. Trimmed during processing. |
|
| Retrieved from NewBaseV4 Contact's reachabilities for |
|
| Retrieved from NewBaseV4 Contact's reachabilities for |
|
| Mapped via |
|
| Set to |
|
| Assigned from the parent customer's GUID. |
| (N/A) | Set to |
| XML string (ERP source) | Deserialized from ERP source XML into |
Discounts & Dashboards
This section outlines how item class value discounts and customer dashboards are handled.
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Assigned from the parent customer's GUID. |
|
| Mapped if |
|
| Mapped from the customer's code. |
|
| Base64 decoded from the |
Special Logic & Filters
Customer Filtering:
Customers with empty
CustomerNameorCustomerCodeare filtered out and logged as invalid.Customers can be skipped if their names start with prefixes defined in the
SkipCustomersWithNamePrefixsetting.
Customer GUID Reactivation:
When the connector is in 'Updater' mode, existing GUIDs of inactive customers (identified by customer codes prefixed with "~") are reused to prevent data loss.
Price Deduplication:
If
EnablePriceDeduplicationis enabled, customer price list IDs (UsesPriceField,ActionPriceList) are migrated to deduplicated versions based on a lookup table (KeySettings.GenericPriceListMigrations).
Address Normalization:
The system ensures that each customer has at least one "Visit" and one "Delivery" address. If only one type exists, it's duplicated to create the other. If no addresses are provided, a dummy address is created to store the ISO2 country code.
Country codes are normalized using
MappedCountriesContextand `CultureHelper.GetCountryFromIso2`.Email addresses within addresses are trimmed, and if empty and marked as main, they can inherit from the customer's main email or other contact emails.
Address lines are parsed into street, house number, and addition components, or formatted back into a single line.
Contact Person Name Filling:
The
FillContactNamemethod attempts to parse a full name into first, middle, and last names, or compose a full name from individual name components. It also sets initials.
Contact ID Generation (Updater Mode):
If the connector is in 'Updater' mode and a
ContactIdis not provided by the ERP for a contact person, a hash code is generated to serve as a temporary ID.
XML Character Removal:
Invalid XML characters are removed from
CustomerandContactPersonobjects before persistence to prevent data corruption.
Customer Notes:
If a
CustomerNoteis present, any existing customer notes from the "BackOffice" source are deleted from theCustomerNotestable, and the new note is inserted. This ensures that only the latest note from the ERP is present.
VAT Handling for USA:
For administrations configured for the USA,
VatCodeis set tonullandVatLiableis set tofalse, aligning with regional tax regulations.
Extra Data Overwrite (from CSV):
The
ProcessExtraDataForCustomermethod allows properties of theCustomerobject to be overwritten by similarly named properties found in theCsvCustomerobject (typically from FTP/CSV imports).
JINT Scripting:
The connector supports custom JINT scripts that can be executed at various stages: "BeforeUpdateCustomers" (before processing any customers), and "UpdateCustomers" (both before and after batch updates). This allows for highly customized transformations or business logic.
Batch Processing:
Customer updates are processed in batches of 100 to optimize performance and reduce database load.
Settings & Prerequisites
The following connector settings and prerequisites influence the behavior of the Customer Update process:
Setting Name | Description | Connector Component |
| When enabled, customers can also be created based on organisations that are linked to debtors, in addition to direct debtors. This expands the scope of customer synchronization. |
|
| The last used sequential ID for generating new customer codes. This value is incremented for each new customer created through the connector. |
|
| A configurable prefix (e.g., "CUST-") to be used for newly generated customer codes. This helps in identifying customers originating from this connector. |
|
| Defines the minimum number of digits for the numeric part of generated customer codes. The default is 5 digits, but can be set to a minimum of 2. For example, a setting of 5 for ID '1' would result in '00001'. |
|
| This setting influences how visit addresses are retrieved for organisations from NewBaseV4. |
|
| Specifies the ISO 2-letter country code that, if matched, will mark a customer as VAT liable. If this setting is left empty, all customers are by default considered VAT liable. |
|
| A comma-separated list of string prefixes. Any customer whose name begins with one of these prefixes will be entirely excluded from the update process. |
|
| When enabled, the connector will attempt to migrate customer price list IDs ( |
|
| The code of a specific price list that will be set as the default |
|
| When enabled, the connector processes item filters provided in |
|
| If true, the description of the customer's assigned price list will be added to their free fields ( |
|
| A JSON string that defines custom mappings between App4Sales fields (or extra fields) and specific fields within the NewBaseV4 entities (Organisation, Debtor, Contact). |
|
Known Limitations
Email Ambiguity in Addresses: If a NewBaseV4 organisation's email is empty, the system may pick the email from the *first random* associated contact. This might not always correspond to the primary contact's email or the intended email for the address.
Customer Note Overwriting: When a
CustomerNoteis provided by the ERP, any existing customer notes marked as from "BackOffice" in App4Sales are deleted and replaced. This effectively overwrites historical notes from this specific source, potentially losing previous versions if not managed externally.Contact ID Stability in Updater Mode: If the connector is in 'Updater' mode and the ERP does not provide a
ContactIdfor a contact person, a hash code is generated. This generated ID might not be stable across connector updates if the underlying data used to generate the hash changes, potentially leading to inconsistencies.