Spector Connector - Create Customer
This document describes how the Spector connector creates or updates customer records in the Specter ERP system. The process involves converting an App4Sales customer object into a Specter-specific format, sending it via an API call, and handling the response. The connector determines whether to create a new customer or update an existing one based on the presence of an App4Sales Customer Code.
Data Source Configuration
The connector communicates with the Specter API at the endpoint: https://api.specter.se. Authentication details and a unique integration ID are used in constructing the API requests. Data is pushed to the Specter system via HTTP POST requests.
Data Mapping Table: Customer Header Fields
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| If |
|
| Mapped directly. Required field in Specter. Max length 100 characters. |
|
| Mapped directly. |
|
| Mapped directly. Max length 20 characters. |
|
| Mapped directly. Max length 30 characters. |
|
| Mapped directly. Max length 50 characters. |
|
| Prioritizes email from |
|
| Prioritizes phone from |
|
| Prioritizes fax from |
|
| The |
|
| If present in |
|
| The |
Hardcoded |
| Defaults to "C" (Company) for new customers; otherwise, it is not sent. Max length 1 character. |
Hardcoded |
| Defaults to "C" (Company) for new customers; otherwise, it is not sent. Max length 1 character. |
|
| If setting |
Data Mapping Table: Contact Person Fields
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Full name of the first contact person. |
|
| First name of the first contact person. Required field in Specter. Max length 50 characters. |
|
| Last name of the first contact person. Required field in Specter. Max length 50 characters. |
|
| Mobile number of the first contact person. Max length 50 characters. |
Data Mapping Table: Visit Address Fields
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Address Line 1 from the App4Sales visit address. Max length 100 characters. |
|
| Address Line 2 from the App4Sales visit address. Max length 100 characters. |
|
| City from the App4Sales visit address. Max length 50 characters. |
|
| ISO 2-letter country code from the App4Sales visit address. Max length 2 characters. |
|
| Postcode from the App4Sales visit address. Max length 10 characters. |
Data Mapping Table: Delivery Address Fields
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Customer name is used as the delivery company name. Max length 100 characters. |
|
| Address Line 1 from the App4Sales delivery address. Max length 100 characters. |
|
| Address Line 2 from the App4Sales delivery address. Max length 100 characters. |
|
| City from the App4Sales delivery address. Max length 50 characters. |
|
| ISO 2-letter country code from the App4Sales delivery address. Max length 2 characters. |
|
| Postcode from the App4Sales delivery address. Max length 10 characters. |
Special Logic & Filters
**Upsert Logic**: The connector employs an upsert (update or insert) strategy. If an App4Sales
CustomerCodeis present,ForceCustomerUpdateandIdentifyByCustomerIdflags are set totruein the Specter payload, indicating an update to an existing customer. IfCustomerCodeis empty, a new customer creation is assumed.**Organizational Form**: For new customer creations (when
CustomerCodeis empty),TypeCustomerandCustomerOrganizationalFormare hardcoded to "C" (Company). These fields are not sent for updates to existing customers, implying Specter maintains their existing values.**Sales Representative ID**: The
SalesRepresentativeIdin Specter is populated from theResIdStringassociated with the App4Sales user's username. This ID is retrieved from theSalesRepstable in the App4Sales database.**Currency**: The currency sent to Specter is derived from the App4Sales PriceList linked to the customer's
UsesPriceField. If this currency is not found, Specter's default currency (SEK) will be used.**Dynamic Fields**: The connector checks for a
CustomerGroupIdwithin theUnknownElementsdictionary of the App4Sales customer object.**Data Truncation**: Fields with
[MaxLength]attributes inSpecterPostCustomerare truncated to their specified maximum length before being sent to Specter.**Required Fields**: Fields marked with
[Required]inSpecterPostCustomer(e.g.,Name,FirstName,SurName,EmailAddress) must have values, otherwise the Specter API may reject the request.
Response & Error Handling
After sending the customer data, the Specter connector processes the API response.
The API response is encapsulated in an
ApiResponseobject, which includes aResultcode, aCode(often the new customer ID), and aMessage.A
Resultcode of1indicates successful processing by Specter.If the response
Resultis not1(or is null), an error is logged. If the responseCodebegins with "ERROR", aCustomerCouldNotCreatedOrUpdatedexception is thrown, preventing the customer from being created or updated in App4Sales.Upon successful creation or update, the returned
Codefrom the Specter API is used to update thecustomer.CustomerCodein App4Sales. ThisCodetypically represents the new Specter customer ID.