SAPB1SL Connector - Customer Creation/Update
This document details the process by which customer data from App4Sales is created or updated in SAP Business One Service Layer (SAP B1SL) via the SAPB1SL connector. This functionality is crucial for synchronizing customer information between App4Sales and the ERP system, supporting both new customer onboarding and maintaining existing customer records.
Trigger & Permissions
The customer creation or update process is triggered from within the App4Sales platform. To enable this functionality, the connector must have the EditCustomer or CreateCustomer flags enabled within the connector's settings (ConnectorInfoInternalIds).
Data Source Configuration
The source of data is the App4Sales Customer model. This data is then transformed and sent to the SAP B1SL via a REST API call to the /BusinessPartners endpoint. Data is pushed from App4Sales to SAP B1SL.
Payload Mapping - App4Sales Customer to SAP B1SL Customer
The following tables detail how App4Sales customer fields are mapped to the SAP B1SL Business Partner (Customer) entity during creation and update operations. Transformations, default values, and conditional logic are also explained.
Core Customer Fields Mapping
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| For new customers: Generated based on |
|
| Directly mapped. |
|
| Directly mapped. |
|
| Directly mapped. |
|
| Directly mapped from App4Sales customer's mobile phone to SAP B1SL's Cellular field. |
|
| Determined by a combination of connector settings and SAP B1SL customer data:
When sending to SAP B1SL, |
|
| Maps to SAP B1SL PriceListCode. If |
|
| Parses |
|
| Mapped if |
|
| Directly mapped. |
|
| If |
(Hardcoded) |
| Set by the |
(Hardcoded) |
| Set to |
|
| Derived from the |
| Dynamic Property | If |
|
| Determined by SAP B1SL |
Address Mapping (BPAddresses)
App4Sales addresses are mapped to SapB1SLAddress objects within the BPAddresses collection of the SapB1SLCustomer. During customer creation, all non-empty addresses from App4Sales are sent. For updates, existing external IDs (RowNumber and AddressName) are used to identify and update addresses in SAP B1SL.
App4Sales Address Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Directly mapped. |
|
| Derived from |
|
| Directly mapped. |
|
| Mapped from App4Sales |
|
| Directly mapped. |
|
| Directly mapped. |
|
| App4Sales |
|
| The customer's code is attached to each address. |
|
| During updates, the |
Contact Person Mapping (ContactEmployees)
Only the App4Sales MainContactPerson is sent to SAP B1SL during customer creation/update. It is mapped to a SapB1SLContactPerson object within the ContactEmployees collection.
App4Sales ContactPerson Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Mapped if not empty and parsable to an integer. |
|
| Directly mapped. |
|
| Directly mapped. |
|
| Directly mapped. |
|
| Directly mapped. |
|
| Directly mapped. |
|
| Directly mapped. |
|
| Directly mapped. |
Dynamic Free Fields Mapping
If the App4Sales customer has DynamicFreeFields and the connector setting CustomCustomerFieldsMapping is configured, custom fields can be mapped to properties of the SapB1SLCustomer, SapB1SLContactPerson, or SapB1SLAddress. The CustomCustomerFieldsMapping setting expects a JSON array of objects with PropertyName (the name of the field in App4Sales) and ObjectName (Customer, ContactPerson, or Address) specifying where to apply the field in SAP B1SL.
Validation & Defaults
Customer Code Generation: For new customers, the
CustomerCodeis either generated using a prefix and a sequential number (controlled byNewCustomersCodePrefixandNewCustomerCodeNumbersettings) or sent as an empty string to allow SAP B1SL to assign it (ifSendEmptyCardCodeis true).VAT Liable Status: The VAT liable status is determined by multiple settings (
UseVatLiableForCustomerVatLiable,UseBillAddressFederalTaxIDAsCustomerVATLiableIndicator) and the presence of VAT numbers in the customer or address data.Price List Code: If the App4Sales
UsesPriceFieldis 0, no price list code is sent to SAP B1SL.Payment Terms Group Code: The App4Sales
PaymentConditionCodemust be an integer to be mapped to SAP B1SLPayTermsGrpCode.Customer Status: When synchronizing customers from SAP B1SL to App4Sales, customers marked as 'invalid' (
Valid='N') or 'frozen' (Frozen='Y') in SAP B1SL will be excluded from synchronization if theExcludeInvalidCustomersFromSyncsetting is enabled.Addresses: App4Sales 'Visit' address types are converted to 'Bill To' (Invoice) addresses when sending to SAP B1SL due to SAP B1SL limitations, but a copy is made during mapping from SAP B1SL to App4Sales to maintain the correct address type in App4Sales.
Language Code: The
LanguageCodefield inSapB1SLCustomeris not currently mapped from App4Sales, as there is no clear source for integer language codes.
Response & Error Handling
After attempting to create or update a customer in SAP B1SL:
Successful Creation: Upon successful creation, SAP B1SL returns the newly created customer object, from which the
CustomerCodeis extracted. ThisCustomerCodeis then stored in App4Sales.Successful Update: SAP B1SL returns a 204 (No Content) response for successful updates. The updated customer details are then fetched from SAP B1SL using the customer's code to ensure data consistency in App4Sales.
Errors: Any exceptions encountered during the API calls (e.g., if the SAP B1SL response for a create operation is null) are caught, logged, and re-thrown, indicating a failure in the customer creation/update process. Error messages are logged with relevant details, such as the customer's name.
Duplicate Detection: The connector primarily relies on the
CustomerCodefor identifying existing customers. For updates, a non-emptyCustomerCodein the App4Sales customer object signals an update operation.
Related Settings & Prerequisites
SendEmptyCardCode: Boolean. If true, theCustomerCodeis sent as an empty string during creation, allowing SAP B1SL to generate it.NewCustomersCodePrefix: String. Prefix used when generating new customer codes (e.g., "A4S").NewCustomerCodeNumber: Integer. Starting number for new customer codes (e.g., 0001).UseVatLiableForCustomerVatLiable: Boolean. If true, the VAT liable status is directly taken from the SAP B1SLVatLiablefield.UseBillAddressFederalTaxIDAsCustomerVATLiableIndicator: Boolean. If true, the VAT liable status is determined by the presence of aFederalTaxIDin BillTo or ShipTo addresses.UseCustomerDiscount: Boolean. If true, the App4Sales customerDiscountis mapped to SAP B1SLDiscountPercent.SendVatNumberInFederalTaxIDField: Boolean. If true, the App4SalesVatCodeis sent to SAP B1SL'sFederalTaxIDfield instead ofVatNumber.CustomerSeries: Integer. Specifies the number series to be used for the customer in SAP B1SL.CustomerClassificationProperty: String. Specifies a property name to use for customer classification from dynamic free fields or existing properties.CustomCustomerFieldsMapping: JSON string. Defines mappings for dynamic free fields from App4Sales to SAP B1SL customer, contact person, or address properties.ExcludeInvalidCustomersFromSync: Boolean. If true, customers with 'invalid' or 'frozen' status in SAP B1SL are excluded from synchronization to App4Sales.
Known Limitations
Language Code Mapping: The language code (
LanguageCode) for SAP B1SL customers is not currently mapped from App4Sales due to a lack of clear source for integer language codes in the App4Sales model.Address Types: SAP B1SL does not explicitly support a "Visit" address type. App4Sales "Visit" addresses are mapped to "Bill To" in SAP B1SL, with a workaround implemented to ensure the correct type is maintained within App4Sales during synchronization.