NetSuite Connector - Create Customer
This document describes the process of creating or updating customer records in NetSuite via the App4Sales platform using the NetSuite Connector. This functionality is primarily handled by the InsertOrUpdateCustomerCommand, which acts as the entry point for customer data from App4Sales into NetSuite. The connector leverages NetSuite's API to manage customer and contact records, including associated addresses, pricing, and other details.
Trigger & Permissions
The customer creation/update flow is enabled when the connector is configured with specific internal IDs. The InsertOrUpdateCustomerCommand is active when either Core.Constants.ConnectorInfoInternalIds.EditCustomer or Core.Constants.ConnectorInfoInternalIds.CreateCustomer flags are set within the connector's information. This controls whether the App4Sales system permits the modification or creation of customer records through this connector.
Data Source Configuration
The primary data source for customer creation/update is the App4Sales Customer object, which encapsulates all relevant customer and contact information. This data is then transformed and sent to the NetSuite ERP system using NetSuite's web services API. The connector pulls necessary configuration settings (e.g., default subsidiary, custom form IDs) from its internal settings to correctly format the data for NetSuite.
Payload Mapping - Customer Header Fields
The following table details the mapping from App4Sales customer fields to NetSuite customer record fields when creating or updating a customer:
App4Sales Field | Source Field (App4Sales Model) | Logic/Notes |
Phone |
| Direct mapping. |
Mobile Phone |
| Mapped from the mobile number of the main contact person associated with the App4Sales customer. |
Fax |
| Direct mapping. |
Company Name |
| Direct mapping. |
| Mapped from the email address of the main contact person associated with the App4Sales customer. | |
Is Inactive |
| Hardcoded to |
External ID |
| Uses the |
VAT Registration Number |
| Direct mapping to NetSuite's VAT registration number field. |
Is Person |
| Hardcoded to |
First Name |
| Mapped from the main contact person's first name, only if the setting "Only Send In Business Data On The Company When Creating A Customer" is |
Last Name |
| Mapped from the main contact person's last name, only if the setting "Only Send In Business Data On The Company When Creating A Customer" is |
Phonetic Name |
| Mapped from the main contact person's full name, only if the setting "Only Send In Business Data On The Company When Creating A Customer" is |
Currency |
| Set as a record reference using the external currency ID from the associated App4Sales price list. |
Payment Terms |
| Set as a record reference using the payment condition code from the App4Sales customer, if not empty. |
Entity ID |
| Only applies when creating a new customer (not an update) and the setting "Setup Entity Id For New Customer" is |
Taxable |
| Only applies when creating a new customer (not an update) and the setting "Setup Vat Liable For New Customer" is |
Custom Form |
| Set as a record reference using the internal ID derived from the |
Entity Status |
| Set as a record reference using the internal ID derived from the |
Language |
| Mapped if the App4Sales |
Custom Fields |
| Custom fields are populated from |
Price Level |
| The price level is determined by the
|
Subsidiary | Determined based on Sales Rep or Default Subsidiary setting | Only applies when creating a new customer. If |
Addresses |
| App4Sales addresses of type "Visit" and "Delivery" are mapped to NetSuite address book entries. The |
Tax Item |
| Based on the |
Payload Mapping - Contact Person Fields
The following table details the mapping from the App4Sales main contact person fields to NetSuite contact record fields:
App4Sales Field | Source Field (App4Sales Model) | Logic/Notes |
Company |
| Set as a record reference linking the contact to the newly created or updated customer in NetSuite. |
First Name |
| Direct mapping. |
Middle Name |
| Direct mapping. |
Last Name |
| Direct mapping. |
Entity ID |
| The full name of the main contact person. |
Mobile Phone |
| Direct mapping. |
| Direct mapping. | |
Phone |
| Direct mapping. |
Phonetic Name |
| The full name of the main contact person. |
Subsidiary | Determined based on Sales Rep or Default Subsidiary setting | Only applies when creating a new contact (not an update). The subsidiary is set according to the same logic as for the customer. |
Validation & Defaults
Required Fields: While not explicitly shown as blocking validation in the connector code for App4Sales fields, NetSuite API calls will typically fail if mandatory fields are missing.
Default Values:
New customers are always created as active (
isInactive = false).Customers are always treated as companies/organizations (
isPerson = false).If
customer.CustomerCodeis empty after the NetSuite operation, an exception is thrown, indicating that a customer code could not be retrieved from the ERP.Country parsing: If a country string cannot be directly matched to a NetSuite country enumeration, it attempts to find a partial match. If no match is found, an exception is thrown.
VAT Liability: The VAT liability (
customer.VatLiable) is mapped based on settings such asUseTaxRegNrForVatliabilityand the customer's delivery address country, or directly from NetSuite'staxablefield or linked tax item.
Response & Error Handling
After submitting customer and contact data to NetSuite:
Customer Upsert: The
CustomersRepository.SendCustomermethod performs an upsert operation (insert or update). It handles the NetSuite API response and extracts the internal ID of the created or updated customer. Thecustomerobject passed by reference is then updated with the NetSuiteinternalIdandCustomerCode.Contact Upsert: The
CustomersRepository.SendContactmethod performs an add or update operation for the contact person. It also handles the NetSuite API response and returns the internal ID of the contact.Contact Attachment: The
CustomersRepository.AttachContactPersonToCustomermethod links the contact person to the customer in NetSuite, optionally assigning a specific contact role (e.g., "Primary Contact").Error Handling:
If NetSuite does not return a customer code after a creation attempt, an
Exceptionis thrown with the message "No customercode retrieved from the ERP".Warnings are logged if contact persons are not created/updated successfully (e.g., "Contact was not updated/created.").
General exceptions during API calls are caught and logged, but then re-thrown to propagate the error.
Special Logic & Filters
Subsidiary Assignment: For new customers, the subsidiary is determined by the connector setting
UseTheSubsidiaryOfTheSalesRep(using the sales rep's subsidiary if enabled) or falls back to theDefaultCustomerSubsidiarysetting.Price Level Assignment: The price level for a new customer is set based on either the sales representative's default price list (if enabled via
UseSalesRepDefaultPriceListForCreateCustomer) or the external ID of the price list selected within App4Sales.Custom Forms and Statuses: The connector attempts to retrieve and apply NetSuite custom form IDs and customer status IDs based on the
CustomerCustomFormNameandCustomerStatusNamesettings respectively.Address Processing: App4Sales addresses are mapped to NetSuite's address book, specifically handling "Visit" and "Delivery" address types and setting default billing/shipping flags.
VAT Tax Items: Appropriate sales tax items are assigned based on the customer's VAT liability and connector settings (
TaxItemValueForVatLiableIsTrue,TaxItemValueForVatLiableIsFalse).
Related Settings & Prerequisites
The following connector settings influence the customer creation process:
Use the subsidiary of the sales rep: (
UseTheSubsidiaryOfTheSalesRep) If true, the sales representative's assigned subsidiary in NetSuite is used for new customers.Default customer subsidiary: (
DefaultCustomerSubsidiary) Specifies the default NetSuite subsidiary name to use if a sales rep's subsidiary is not applicable or found.Primary contact role name: (
PrimaryContactRoleName) The name of the contact role in NetSuite to assign to the main contact person.Customer custom form name: (
CustomerCustomFormName) The name of a custom customer form in NetSuite to be used for new customer records.Customer status name: (
CustomerStatusName) The name of a customer status in NetSuite to assign to new customer records (e.g., "Lead", "Qualified").Only send in business data on the company when creating a customer: (
OnlySendInBusinessDataOnTheCompanyWhenCreatingACustomer) If true, individual contact details (first name, last name) from the main contact person are not sent to the NetSuite customer record.Setup entity id for new customer: (
SetupEntityIdForNewCustomer) If true, the customer's company name is used as the NetSuite entity ID for new customers.Setup vat liable for new customer: (
SetupVatLiableForNewCustomer) If true, the customer's VAT liability status from App4Sales is explicitly set in NetSuite upon creation.Tax item value for vat liable is true: (
TaxItemValueForVatLiableIsTrue) The name of the NetSuite Sales Tax Item to use when a customer is VAT liable.Tax item value for vat liable is false: (
TaxItemValueForVatLiableIsFalse) The name of the NetSuite Sales Tax Item to use when a customer is not VAT liable.Use sales rep default price list for create customer: (
UseSalesRepDefaultPriceListForCreateCustomer) If true, the default price list assigned to the sales representative is used for new customers.Use tax reg nr for vat liability: (
UseTaxRegNrForVatliability) If true, the customer's VAT registration number and country are used to determine VAT liability.Use country for tax reg nr vat liability: (
UseCountryForTaxRegNrVatLiability) The country code used in conjunction withUseTaxRegNrForVatliabilityto determine VAT liability based on geographical rules.Customer discount custom field name: (
CustomerDiscountCustomFieldName) The script ID of a custom field in NetSuite where customer discount information is stored.Custom Field For Company Name: (
CustomFieldForCompanyName) Script ID of a custom field to store/retrieve the company name.Custom Field For Customer Manager: (
CustomFieldForCustomerManager) Script ID of a custom field to store/retrieve the customer manager.Custom Field For Chamber Of Commerce: (
CustomFieldForChamberOfCommerce) Script ID of a custom field to store/retrieve the Chamber of Commerce code.Customer Free Fields Configuration: (
CustomerFreeFieldsConfiguration) JSON configuration for mapping arbitrary App4Sales free fields to NetSuite custom fields.Store Customer Category Field To Free Fields: (
StoreCustomerCategoryFieldToFreeFields) If true, the NetSuite customer category field is stored as a free field in App4Sales.
Known Limitations
The connector assumes that if a customer code is not returned by NetSuite after creation, the operation has failed.
Country mapping relies on string matching and might require exact or very close matches to NetSuite's country enumerations.