CSV Connector - Create Customer
This functionality handles the creation of a new customer by exporting customer data from App4Sales to a CSV file. The system generates a CSV file containing the new customer's information, which can then be processed by an external system. This is not a direct API call to an ERP, but a file-based export.
Trigger & Permissions
A customer export is triggered manually through the App4Sales backoffice or via an automated process that calls the export functionality. The functionality is available if the connector is configured for customer exports. The `GetCustomersExportData` method is called to generate the CSV data.
Payload Mapping
The following tables describe the mapping from App4Sales customer data to the fields in the output CSV file.
Customer Header
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
Code | CustomerCode | The App4Sales customer code. |
CustomerCode | CustomerCode | The App4Sales customer code. (repeated for compatibility) |
Name | CustomerName | The name of the customer. |
CustomerName | CustomerName | The name of the customer. (repeated for compatibility) |
Sysmodified | Sysmodified | The last modification date of the customer data. |
Manager | CustomerManager | The account manager assigned to the customer. |
CustomerManager | CustomerManager | The account manager assigned to the customer. (repeated for compatibility) |
Phone | MainContactPerson.Phonenumber | The phone number of the main contact person. |
CustomerPhone | Phone | The customer's main phone number. |
Language | LanguageCode | The language code for the customer (e.g., "en", "nl"). |
LanguageCode | LanguageCode | The language code for the customer (e.g., "en", "nl"). (repeated for compatibility) |
Discount | Discount | The customer's standard discount percentage. Defaults to 0 if not set. |
MainContactPerson.Email | The email address of the main contact person. | |
ContactFullName | MainContactPerson.FullName | The full name of the main contact person. |
VatNumber | VatCode | The VAT (Value Added Tax) number of the customer. |
VATCode | VatCode | The VAT (Value Added Tax) number of the customer. (repeated for compatibility) |
VatLiable | VatLiable | A boolean indicating if the customer is liable for VAT. |
ChamberOfCommerceCode | ChamberOfCommerceCode | The customer's Chamber of Commerce registration number. |
PaymentCondition | PaymentConditionCode | The description of the customer's payment condition. This is looked up from the list of all payment conditions. |
ItemFilter | ItemFilter | The itemfilter that is assigned to a customer. |
Addresses
The connector exports up to two addresses: a visiting address and a delivery address. It also exports a main address which is used for top-level address fields.
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
VisitAddress1 | Addresses (AddressType = "Visit").AddressLine1 | The first line of the visiting address. |
VisitAddress2 | Addresses (AddressType = "Visit").AddressLine2 | The second line of the visiting address. |
VisitAddress3 | Addresses (AddressType = "Visit").AddressLine3 | The third line of the visiting address. |
VisitCity | Addresses (AddressType = "Visit").City | The city of the visiting address. |
VisitCountry | Addresses (AddressType = "Visit").Country | The country of the visiting address. |
VisitPostCode | Addresses (AddressType = "Visit").PostCode | The postal code of the visiting address. |
VisitState | Addresses (AddressType = "Visit").State | The state of the visiting address. |
DeliveryAddress1 | Addresses (AddressType = "Delivery").AddressLine1 | The first line of the delivery address. |
DeliveryAddress2 | Addresses (AddressType = "Delivery").AddressLine2 | The second line of the delivery address. |
DeliveryAddress3 | Addresses (AddressType = "Delivery").AddressLine3 | The third line of the delivery address. |
DeliveryCity | Addresses (AddressType = "Delivery").City | The city of the delivery address. |
DeliveryCountry | Addresses (AddressType = "Delivery").Country | The country of the delivery address. |
DeliveryPostCode | Addresses (AddressType = "Delivery").PostCode | The postal code of the delivery address. |
DeliveryState | Addresses (AddressType = "Delivery").State | The state of the delivery address. |
City | Addresses (IsMainAddress = true).City | The city of the main address. |
Country | Addresses (IsMainAddress = true).Country | The country of the main address. |
CountryCode | Addresses (IsMainAddress = true).IsoCode | The ISO code of the country of the main address. |
Main Contact Person
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
ContactEmail | MainContactPerson.Email | The email of the main contact person. |
ContactFax | Fax | The fax number of the customer. |
ContactPhone | MainContactPerson.Phonenumber | The phone number of the main contact person. |
Validation & Defaults
The export process relies on the data being correctly formatted within App4Sales.
If a discount value is not present, it defaults to
0.The payment condition description is retrieved based on the
PaymentConditionCode. If the code is not found, the field will be empty.Address fields (Visiting, Delivery, Main) are populated from the first address of the corresponding type found in the customer's address list. If no address of a specific type exists, the fields will be empty.
Response & Error Handling
The method GetCustomersExportData returns a byte array containing the CSV data encoded in UTF-8. If the specified export format is not CSV, an InvalidOperationException is thrown. If the export definition is invalid, an ArgumentException is thrown. The calling process is responsible for handling these exceptions and writing the data to a file.
Related Settings & Prerequisites
Use template for CSV Export: If enabled, the export will use a custom CSV template. This setting is labeled
UseTemplateForCSVExportToFtpin the configuration.