FtpXml Connector - Create Customer
Overview
The FtpXml connector facilitates customer creation by converting App4Sales customer data into an XML file and uploading it to a configured FTP/SFTP server. An external process, typically within the ERP system, is expected to monitor this FTP location, retrieve the XML file, and integrate the new customer information into the ERP. This process is triggered when a new customer is created or an existing one is updated within App4Sales.
Trigger & Permissions
The customer creation flow is initiated by the InsertOrUpdateCustomerCommand, which is subsequently handled by the OptA4SNewCustomers method in the FtpXml connector. For this functionality to be active, the following connector information flags must be enabled in the App4Sales administration:
Create Customer(corresponds toConstants.ConnectorInfoInternalIds.CreateCustomer)Edit Customer(corresponds toConstants.ConnectorInfoInternalIds.EditCustomer)
Data Source Configuration
The FtpXml connector functions as a file transfer mechanism rather than a direct API integration. The customer data, serialized as an XML file, is uploaded to an FTP/SFTP server configured in the App4Sales administration.
FTP/SFTP Server Details: Configured via the
Addressfield inSession.Administration.Address(e.g.,ftp://yourhost.com/pathorsftp://yourhost.com/path). This specifies the host, port, and base directory.Authentication: Uses the username and password provided in the App4Sales administration for the FTP/SFTP connection.
Upload Path: The generated customer XML files are uploaded to
[Base Folder Name]/customers/[customerCode].xmlon the FTP/SFTP server, where[Base Folder Name]is derived from the configured address.File Format: XML, adhering to the
<NewCustomers>and<Customer>schema defined internally by App4Sales.
Payload Mapping - Core Customer Fields
The following table details the mapping from App4Sales internal Customer model fields to the XML elements in the generated Customer.xml file.
App4Sales Field | Source Field (XML Element Name) | Logic/Notes |
|
| Uses existing customer code or defaults to an empty string if null in |
|
| Direct mapping. |
|
| Generated if empty; otherwise, uses the provided GUID. |
|
| Full name of the main contact person. |
|
| Prioritizes main contact person's email; falls back to customer's email. Defaults to empty string if neither is available. |
|
| Direct mapping. |
|
| Fax number from visit address, falling back to delivery address. |
|
| Prioritizes main contact person's phone number; falls back to customer's phone. Defaults to empty string if neither is available. |
|
| Direct mapping. |
Derived |
| Current timestamp when the XML is generated ( |
|
| Direct mapping. |
|
| ISO 2-letter country code from visit address, falling back to delivery address. Defaults to "nl" if neither is available. |
|
| Converted to string using invariant culture. |
|
| Converted to string using invariant culture. |
|
| Direct mapping. |
|
| Converted to "True" or "False" string. |
|
| Direct mapping. |
|
| Mobile number of the main contact person. |
|
| Direct mapping. |
|
| Direct mapping. |
Payload Mapping - Address Fields
Address information for the customer is mapped from the App4Sales Address objects, prioritizing visit addresses over delivery addresses.
App4Sales Field | Source Field (XML Element Name) | Logic/Notes |
|
| Visit address line 1. |
|
| Visit address line 2. |
|
| Visit address postal code. |
|
| Visit address city. |
|
| Visit address state. |
|
| Delivery address line 1. |
|
| Delivery address line 2. |
|
| Delivery address postal code. |
|
| Delivery address city. |
|
| Delivery address state. |
Payload Mapping - Dynamic Custom Fields
App4Sales Field | Source Field (XML Element Name) | Logic/Notes |
| Dynamic (Key of Dictionary) | Any key-value pairs in the |
Validation & Defaults
Customer GUID: If an incoming customer object has an empty
CustomerGuid, a new GUID is automatically generated.Customer Code: The
customer.CustomerCodeis ensured to be non-null by defaulting to an empty string before processing.Country Code: If both visit and delivery addresses lack an ISO 2-letter country code, the
countryCodedefaults to "nl".Email/Phone: If neither the main contact person nor the customer has an email/phone, the respective XML fields will be empty strings.
Response & Error Handling
After processing, the FtpXml connector returns a string indicating the outcome.
Success: If the customer XML file is successfully uploaded to the FTP/SFTP server, the connector returns a string prefixed with
"Succes:"(Constants.RequestParameter.SUCCESS_CUSTOMER) followed by thecustomerCode. This customer code is then stored back into the App4Sales internal customer record.Error during upload: If an exception occurs during the FTP/SFTP upload process, the connector returns an error message prefixed with
"ERROR: ", including details about the exception.Error during internal customer code lookup: A basic check for the customer code in the internal database is performed. If this query encounters an error, the connector immediately returns an error message prefixed with
"ERROR: ".
Special Logic & Filters
Duplicate Detection: The connector performs a lightweight duplicate check by querying the internal App4Sales database for an existing customer with the same
customerGUIDas provided in the incoming XML. This is primarily for internal consistency and does not involve checking for duplicates in the external ERP system.XML Generation and Upload: The primary logic involves generating an XML file with customer data and uploading it to a specified FTP/SFTP directory. The connector relies on an external system to pick up and process these XML files.
Logging: The generated customer XML payload is logged at an "Essential" level, providing visibility into the data being sent to the ERP.
Known Limitations
No Direct ERP API Integration: The FtpXml connector does not directly interact with the ERP system via an API. It relies solely on file transfer (FTP/SFTP) for data exchange. This means real-time feedback or complex transactional operations with the ERP are not natively supported by the connector itself.
Basic Duplicate Checking: Duplicate checking for customers is performed against the internal App4Sales database based on
customerGUID. There is no inherent mechanism within this connector to check for existing customers directly within the target ERP system before uploading the XML file. The ERP system is responsible for handling duplicates on its end when processing the XML.Asynchronous Processing: The customer creation is an asynchronous process from the perspective of App4Sales. Once the XML is uploaded to the FTP/SFTP server, the success or failure of its processing by the ERP system is not directly communicated back to the connector in real-time. The connector only confirms the successful upload of the file.