CSV Connector - Customer Update
This document describes the process of updating customers, including their addresses, contact persons, and other related data, using the CSV connector. The process reads customer data from a CSV file, transforms it, and saves it into the App4Sales database. The update is handled by the CustomerUpdateHandler, which contains the core logic for processing the data.
Data Source Configuration
The connector retrieves customer data from .csv files. The source can be configured in two ways:
FTP/SFTP/FTPS: The connector downloads all
*.csvfiles from a specific directory on a remote server. The server address, path, and credentials are set in the connector's administration settings. For the customer sync, it looks in the folder configured at the 'Address' field, in a subfolder named 'customers'.File Upload: A CSV file can be uploaded directly during a manual sync.
The CSV parsing is configured with the following settings:
Separator Character: Defined by the
SeparatorCharactersetting in the connector configuration. It defaults to a semicolon (;) if not specified.Headers: The connector expects the first line of the CSV file to be a header row.
Data Mapping: Customer
The following table shows the mapping from the source CSV file fields to the App4Sales customer fields.
App4Sales Field | Source Field (CSV) | Logic/Notes |
CustomerCode | CustomerCode / Code | Mapped from |
CustomerName | CustomerName / Name | Mapped from |
CustomerGuid | - | An internal identifier. The system tries to find an existing GUID based on the |
VatCode | VATCode | Directly mapped from |
VatLiable | VatLiable | Directly mapped from |
ChamberOfCommerceCode | ChamberOfCommerceCode | Directly mapped from |
LanguageCode | LanguageCode / Language | Mapped from |
Discount | Discount | Directly mapped from |
PaymentConditionCode | PaymentConditionCode / PaymentCondition | Mapped from |
CustomerManager | CustomerManager / Manager | Mapped from |
Sysmodified | Sysmodified | Directly mapped from |
UsesPriceField | UsesPriceField | Mapped from |
ActionPriceList | ActionPriceList | Mapped from |
Website | Website | Directly mapped from |
Phone | CustomerPhone / Phone | Mapped from |
Directly mapped from | ||
Fax | Fax | Directly mapped from |
CustomerEnabled | - | Hardcoded to |
PasswordWebshop | - | Set to |
Domain Specifics
Addresses
The connector processes delivery and visit addresses from the CSV. It ensures that if one address type (Visit or Delivery) is provided, the other is created as a copy. If no addresses are provided, a dummy address might be created to store the country code.
App4Sales Field | Source Field (CSV) | Logic/Notes |
AddressLine1 | VisitAddress1 / DeliveryAddress1 | The full address line. The system attempts to parse this into separate Street, Number, and Addition components. |
PostCode | VisitPostCode / DeliveryPostCode | Directly mapped. |
City | VisitCity / DeliveryCity | Directly mapped. |
State | VisitState / DeliveryState | Directly mapped. |
Country | VisitCountry / DeliveryCountry | Directly mapped. If empty, it's set to the value of |
Iso2 | VisitCountryCode / DeliveryCountryCode | The country code is mapped from the source. If a mapping exists in the 'Mapped Countries' table, the mapped value is used. Otherwise, the source value is trimmed. If the source is empty, the system attempts to derive it from the |
- | The email for the main address is inherited from the customer's main email if it's not provided on the address itself. | |
IsMainAddress | - | The first visit address and the first delivery address are marked as the main address for their respective types. |
Contact Persons
Contact persons are linked to customers. If a main contact person is provided, it's flagged accordingly. If no main contact is specified, the first contact person in the list is automatically designated as the main contact.
App4Sales Field | Source Field (CSV) | Logic/Notes |
FullName | ContactFullName | Mapped from |
ContactEmail | Mapped from | |
Phone | ContactPhone | Directly mapped. |
Fax | ContactFax | Directly mapped. |
IsMainContactPerson | - | Set to |
PasswordWebshop | - | Set to |
Extra Data & Free Fields
The connector can enrich customer data with information from a secondary 'extra data' CSV file. This file is typically located in an FTP folder. Properties from this extra file overwrite any existing values on the customer record if the property names match.
Fields from the extra data file with a name starting with
FreeField_(e.g.,FreeField_CustomInfo) are added to the customer's free fields. The caption will be 'CustomInfo'.If the
CustomerItemFiltersetting is enabled, fields from the extra data file starting withItemFilter_are used to create fixed item filters for the customer. For example, a column namedItemFilter_Brandwith a value ofBrandA~BrandBwould restrict the customer to seeing only items from BrandA and BrandB.
Discounts & Dashboards
Discounts: Item class discounts can be provided. Any discount with a value greater than 0 is stored.
Dashboards: A Base64-encoded dashboard layout can be provided in the
CustomerDashboardfield. This is decoded and stored separately. The field on the customer object is then cleared.Notes: A customer note can be provided in the
CustomerNotefield. When a note is supplied, all existing notes from the 'BackOffice' salesrep for that customer are deleted and the new note is inserted.
Special Logic & Filters
Customer Validation: Rows in the CSV are skipped if both
CustomerCode(orCode) andCustomerName(orName) are empty. A warning is logged for invalid records.Batch Processing: Customers are processed in batches of 100.
Reactivation: The system is designed to reactivate customers whose codes were previously prefixed with a tilde (~), preserving their history by reusing the existing GUID.
Address Normalization: The system ensures that every customer has both a visit and a delivery address. If one is missing, it's created by copying the other. Country codes (ISO2) are normalized using a mapping table or derived from the country name.
Scripting Hooks: The connector executes two Jint scripts if they are configured:
BeforeUpdateCustomers(before processing) andUpdateCustomers(after processing each batch).
Related Settings & Prerequisites
SeparatorCharacter: Defines the delimiter for CSV files. Defaults to ';'.CleanData: If enabled, all existing customers are wiped before the sync.EnablePriceDeduplication: If enabled, pricelist IDs are migrated according to a predefined mapping.DefaultActionPriceListCode: If set, all customers without a specific action pricelist will be assigned the one specified here.CustomerItemFilter: Enables the creation of fixed item filters for customers from the extra data file.