Skip to main content

FTP - Create customer

FTP Connector - Create Customer This document describes the customer creation process for the App4Sales FTP Connector. This function hand...

Updated over a week ago

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

customerCode

Internal Parameter

Customer code generated by the App4Sales platform.

customerName

customer.CustomerName

Directly mapped from the XML payload.

languageCode

customer.LanguageCode

Directly mapped from the XML payload.

VatLiable

customer.VatLiable

Boolean value from XML converted to "1" if true, "0" if false.

discount

customer.Discount

Directly mapped from the XML payload.

customerManager

request.SalesRep?.Username

The username of the sales representative associated with the request.

paymentConditionCode

customer.PaymentCondition

Directly mapped from the XML payload.

chamberOfCommerce

customer.ChamberOfCommerceCode

Directly mapped from the XML payload.

VATCode

customer.VatCode

Directly mapped from the XML payload.

contactFullName

customer.ContactFullName

Directly mapped from the XML payload.

contactPhone

customer.Phone

Directly mapped from the XML payload.

contactEmail

customer.Email

Directly mapped from the XML payload.

contactFax

customer.Fax

Directly mapped from the XML payload.

usesPricefield

customer.UsesPrice

Directly mapped from the XML payload.

deliveryAddress1

customer.DeliveryAddress1

Directly mapped from the XML payload.

deliveryAddress2

customer.DeliveryAddress2

Directly mapped from the XML payload.

deliveryCity

customer.DeliveryCity

Directly mapped from the XML payload.

deliveryPostCode

customer.DeliveryPostCode

Directly mapped from the XML payload.

deliveryCountry

customer.CountryCode

Directly mapped from the XML payload.

visitAddress1

customer.VisitAddress1

Directly mapped from the XML payload.

visitAddress2

customer.VisitAddress2

Directly mapped from the XML payload.

visitCity

customer.VisitCity

Directly mapped from the XML payload.

visitPostCode

customer.VisitPostCode

Directly mapped from the XML payload.

visitCountry

customer.CountryCode

Directly mapped from the XML payload.

_<UnknownElementName>

UnknownElements

Any additional elements found in the incoming XML payload are included as _Key, Value pairs.

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 VatLiable field 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.")

Did this answer your question?