FTP Connector - Create Customer
This document describes the customer creation process for the App4Sales FTP Connector. This function handles new customer submissions from the App4Sales platform, converts them into a CSV format, and uploads them to a specified FTP server. The primary purpose is to enable the external ERP system to receive new customer data for processing.
Trigger & Permissions
The customer creation flow is triggered when a new customer is submitted from the App4Sales mobile application or through a backoffice sync. This process is enabled by the connector info flags CreateCustomer and EditCustomer, which must be active in the connector's configuration for this functionality to be available.
Data Source Configuration
The connector receives customer data as an XML payload within an InternalRequest. This XML is deserialized into an XmlCustomer object. The App4Sales platform also provides an internal customerCode, which is either generated or retrieved based on the customer's GUID before the data is prepared for export.
Payload Mapping
The following table details how fields from the incoming App4Sales customer data (XmlCustomer) and internal parameters are mapped to the outgoing CSV file. The CSV file is generated with a semicolon (;) as the delimiter.
App4Sales Field | Source Field (XML/Internal) | Logic/Notes |
| Internal Parameter | Customer code generated by the App4Sales platform. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Boolean value from XML converted to "1" if true, "0" if false. |
|
| Directly mapped from the XML payload. |
|
| The username of the sales representative associated with the request. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
|
| Directly mapped from the XML payload. |
| UnknownElements | Any additional elements found in the incoming XML payload are included as |
Validation & Defaults
The connector first checks if a valid customer object is received. If the customer object is null after deserialization, an error is returned.
The
VatLiablefield is converted from a boolean type to a string, represented as "1" for true and "0" for false.
Response & Error Handling
Upon successful processing, the customer data is converted to a CSV string, written to a temporary local file, and then uploaded to the configured FTP server in the /Customers/ subdirectory. If the FTP upload is successful, the method returns a success message including the customerCode. In case of any errors during the FTP upload process, an error message detailing the exception is logged and returned to the App4Sales UI. The connector also handles the creation of the local export directory if it does not already exist, and it will overwrite any existing file with the same name.
Special Logic & Filters
The entire customer export process is conditional on the "Send customer to FTP" setting. If this setting is disabled, no customer CSV file will be generated or uploaded to the FTP server.
Any unrecognized XML elements in the incoming customer payload are appended to the CSV output with an underscore prefix (e.g.,
_CustomField).
Related Settings & Prerequisites
Send customer to FTP: A boolean setting that, when enabled, allows the connector to export new customer data to the FTP server. This setting is crucial for preventing errors in environments where a "Customers" folder might not exist on the FTP server.
Known Limitations
The current implementation for sending customers to the FTP server behaves identically to the CSV connector's customer handling. There are no FTP-specific functionalities for direct manipulation of the customer on the FTP server beyond uploading the generated CSV file. (Refer to the TODO comment in the code: "Set the customer on the FTP Server, now it is the same behaviour as the CSV Connector.")