Skip to main content

King - Create customer

King Connector - Create Customer The King connector can create new customers when sending an order with a dropshipment address. This funct...

Updated over a week ago

King Connector - Create Customer

The King connector can create new customers when sending an order with a dropshipment address. This functionality is only active when the setting "Create dropshipment customer in King" is enabled. The new customer is created as part of the order sending process. The connector generates an order XML file containing the new customer's data and uploads it to the FTP server. The King ERP system is then responsible for creating the customer from this file.

Trigger & Permissions

A new customer is created if the following conditions are met:

  • The "Create dropshipment customer in King" setting is enabled in the connector configuration.

  • An order is created with a dropshipment address (AlternateAddress).

  • The dropshipment address contains sufficient information (see validation section).

The creation is part of the `SendOrderToBackoffice` flow.

Payload Mapping

The new customer's data is derived from the order and its alternate (dropshipment) address. The following table shows the mapping from the App4Sales order object to the new customer object.

App4Sales Field

Source Field (API/Excel/DB)

Logic/Notes

CustomerGuid

Derived

A new GUID is generated for the new customer.

UsesPriceField

order.Customer.UsesPriceField

Copied from the original customer on the order.

Addresses

order.AlternateAddress, order.InvoiceAddress

The alternate (dropshipment) address and invoice address from the order are added to the new customer.

ContactPersons

order.ConsumerEmail, order.ConsumerName, order.ConsumerPhoneNumber

A new main contact person is created using the consumer's email, name, and phone number from the order.

CustomerName

order.AlternateAddress.EstablishmentName or order.ConsumerName

The establishment name from the alternate address is used. If empty, the consumer's name is used as a fallback.

Email

order.ConsumerEmail

The consumer's email address from the order.

City

order.AlternateAddress.City

The city from the alternate address.

Country

order.AlternateAddress.Country

The country from the alternate address.

CountryCode

order.AlternateAddress.Iso2

The ISO2 country code from the alternate address.

CustomerEnabled

Hardcoded

Set to `true`.

IsDropShipmentCustomer

Hardcoded

Set to `true`.

Phone

order.ConsumerPhoneNumber

The consumer's phone number from the order.

VatLiable

Hardcoded

Set to `true`.

ExtraData

Derived

A JSON object is created containing `IsDropShipmentCustomer` and `ConsumerMail`.

debtorGroup

Settings.DebtorGroupForDropshipmentCustomers

If the setting 'Debtor group for dropshipment customers' is filled, this value will be added to the customer's unknown elements.

Validation & Defaults

Before a dropshipment customer is created, the system validates if the alternate address on the order contains enough information. The following fields are required:

  • Establishment Name or Consumer Name

  • Consumer Email

  • Address Line 1 or Street

  • City

  • Postal Code

  • Country ISO2 Code

If any of these fields are missing, the customer creation is skipped.

Response & Error Handling

The customer creation is embedded within the order sending process. The `InsertOrUpdateCustomerProcess` will first save the new customer to the App4Sales database. The entire order, including the new customer data, is then written to an XML file and uploaded to the FTP server. The King ERP system is expected to process this file. There is no direct feedback mechanism from the ERP to confirm the customer was created successfully. If the FTP upload fails, the order number is reset in App4Sales, and an error is logged. Any errors from the King ERP system itself would need to be checked in the King system.

Did this answer your question?