Customer Mapping Schema for Orders
How BigCommerce Customers Map to Business Central
1. Overview
When an order is imported from BigCommerce, the system automatically finds or creates a Business Central customer based on the order data. This document explains the three main paths and seven customer search strategies used.
Visual Flowcharts
Flowchart 1: Main Order Processing Flow
graph TD
Start["📦 Order Imported"] --> CheckCompany{"CompanyIdSXE > 0?<br/>B2B Company?"}
CheckCompany -->|YES| GetCompany["Get Company<br/>CustomerNo"]
GetCompany --> SetBoth1["Assign Both:<br/>SellToCustomerNo<br/>BillToCustomerNo"]
SetBoth1 --> Complete1["✅ Complete"]
CheckCompany -->|NO| CheckGuest{"CustomerId = 0?<br/>Guest Order?"}
CheckGuest -->|YES| FindTemplate["Find Guest Template<br/>by Country + Type"]
FindTemplate --> AssignGuest["Assign<br/>GuestCustomerNo"]
AssignGuest --> Complete2["✅ Complete"]
CheckGuest -->|NO| RegisteredCust["Registered Customer<br/>CustomerId > 0"]
RegisteredCust --> GetBCCust["Get/Import Customer<br/>from BigCommerce"]
GetBCCust --> HasLink{"CustomerNo<br/>already linked?"}
HasLink -->|YES| UseExisting["Use Existing<br/>BC Customer"]
HasLink -->|NO| ExecuteSearch["Execute 7-Strategy<br/>Search<br/>See Flowchart 2"]
UseExisting --> SetSellTo["Assign<br/>SellToCustomerNo"]
ExecuteSearch --> FoundCustomer["Customer Found<br/>or Created"]
FoundCustomer --> SetSellTo
SetSellTo --> MapBillTo["Map Bill-To Address<br/>Match or Fall Back<br/>to SellToCustomerNo"]
MapBillTo --> SetBillTo["Assign<br/>BillToCustomerNo"]
SetBillTo --> OrderReady["✅ Order Ready<br/>for Processing"]
Complete1 --> OrderEnd["Create Sales Document"]
Complete2 --> OrderEnd
OrderReady --> OrderEnd
style Start fill:#90EE90
style OrderEnd fill:#87CEEB
style OrderReady fill:#90EE90
style ExecuteSearch fill:#FFD700
Flowchart 2: Seven-Strategy Customer Search
graph TD
Start["Start 7-Strategy Search<br/>Find BC Customer Match"] --> S1["Strategy 1<br/>Search Metafields"]
S1 --> C1{"Found<br/>BC Customer?"}
C1 -->|YES| Return["✅ Return<br/>Customer Found"]
C1 -->|NO| S2["Strategy 2<br/>Search Attributes"]
S2 --> C2{"Found?"}
C2 -->|YES| Return
C2 -->|NO| S3["Strategy 3<br/>Search Form Fields"]
S3 --> C3{"Found?"}
C3 -->|YES| Return
C3 -->|NO| S4["Strategy 4<br/>Email Match<br/>case-insensitive"]
S4 --> C4{"Found?"}
C4 -->|YES| Return
C4 -->|NO| S5["Strategy 5<br/>Phone Match<br/>case-insensitive"]
S5 --> C5{"Found?"}
C5 -->|YES| Return
C5 -->|NO| S6["Strategy 6<br/>Company Name Match<br/>case-insensitive"]
S6 --> C6{"Found?"}
C6 -->|YES| Return
C6 -->|NO| S7["Strategy 7<br/>Customer Template"]
S7 --> GetAddr["Get First Address"]
GetAddr --> MapCountry["Map ISO2 Country<br/>to Country/Region Code"]
MapCountry --> FindTemplate["Find Template<br/>by Country + Type"]
FindTemplate --> TemplateFound{"Template<br/>Found?"}
TemplateFound -->|NO| RetryDefault["Retry with<br/>Default Country"]
RetryDefault --> DefaultFound{"Found?"}
DefaultFound -->|NO| NoCustomer["❌ No Customer Found"]
DefaultFound -->|YES| CheckSource
TemplateFound -->|YES| CheckSource["Check Template<br/>Source Type"]
CheckSource --> IsDefault{"Default<br/>Customer No.?"}
IsDefault -->|YES| GetExisting["Get Existing<br/>BC Customer"]
GetExisting --> Return
IsDefault -->|NO| IsTemplate{"Customer<br/>Template?"}
IsTemplate -->|YES| CreateNew["✨ Create NEW<br/>BC Customer<br/>from Template"]
CreateNew --> Populate["Populate Fields:<br/>Name, Contact, Phone,<br/>Email, Address, Country"]
Populate --> Return
IsTemplate -->|NO| NoCustomer
Return --> Done["Search Complete<br/>Customer Mapped"]
NoCustomer --> Done
style Start fill:#FFD700
style Done fill:#90EE90
style Return fill:#90EE90
style CreateNew fill:#FFD700
style NoCustomer fill:#FF6B6B
2. Three Order Processing Paths
Path 1: B2B Company Order (CompanyIdSXE > 0)
When an order is linked to a BigCommerce B2B company:
- Look up the company in the system
- Get the pre-assigned BC Customer No. from the company
- Use this customer for both Sell-To and Bill-To
Key Table: CompanySXE
Path 3: Registered Customer (CustomerId > 0)
When an existing BigCommerce customer places an order:
- Get/Import customer data
- Find BC customer match using 7 strategies
- Create new customer if no match found
3. BigCommerce to BC Field Mappings
When Creating a NEW B2B Customer
| BigCommerce | BC Field | Example |
|---|---|---|
| Company | Customer.Name | Acme Corporation |
| FirstName+LastName | Customer.Contact | John Smith |
| Phone | Customer.Phone No. | +1-555-1234 |
| Customer.E-Mail | john@acme.com | |
| Address1 | Customer.Address | 123 Business Street |
| Address2 | Customer.Address 2 | Suite 100 |
| City | Customer.City | Springfield |
| PostCode | Customer.Post Code | 12345 |
| StateOrProvince | Customer.County | Illinois |
| Country ISO2 | Customer.Country/Region Code | US |
Automatically generates customer No. from BC template
When Creating a NEW B2C Customer
| BigCommerce | BC Field | Example |
|---|---|---|
| FirstName+LastName | Customer.Name | John Smith |
| (None) | Customer.Contact | (Leave empty) |
| Phone | Customer.Phone No. | +1-555-1234 |
| Customer.E-Mail | john@example.com | |
| Address1 | Customer.Address | 123 Main Street |
| Address2 | Customer.Address 2 | Apt 4B |
| City | Customer.City | Springfield |
| PostCode | Customer.Post Code | 12345 |
| StateOrProvince | Customer.County | Illinois |
| Country ISO2 | Customer.Country/Region Code | US |
Automatically generates customer No. from BC template
4. Seven Customer Search Strategies
These strategies are tried IN ORDER when a BigCommerce customer has no prior BC link.
Strategy 1: Metafields
Search custom metafield values mapped to BC Customer.SystemId or No. When it works: If BigCommerce stores BC customer references as metafields
Strategy 2: Customer Attributes
Search customer attribute values mapped to BC Customer.SystemId or No. When it works: If BigCommerce stores BC customer references as attributes
Strategy 3: Form Fields
Search custom form field values containing BC Customer.SystemId or No. When it works: If BC customer info captured through custom forms
Strategy 4: Email Address (Case-Insensitive)
Filter BC customers by email (case-insensitive) Example: john@example.com matches JOHN@EXAMPLE.COM When it works: When BC customer has same email
Strategy 5: Phone Number (Case-Insensitive)
Filter BC customers by phone (case-insensitive) Example: +1-555-1234 matches 1.555.1234 When it works: When BC customer has same phone
Strategy 6: Company Name (Case-Insensitive)
Filter BC customers by name (case-insensitive) Example: Acme Corp matches ACME CORPORATION When it works: When BC customer has same company name
Strategy 7: Customer Template (Creates if Needed)
Find template by country and business type, then CREATE customer if needed
Process:
- Get customer's first address from BigCommerce
- Map ISO2 country code to BC Country/Region Code
- Find template matching country code + customer type (B2B or B2C)
- Either use existing BC customer or create new one from template
When it works: Default fallback - finds or creates based on location and type
6. Key Business Central Tables
Customer Table
Contains all BC customers with fields:
- No. (auto-generated from template)
- Name (Company for B2B, Full Name for B2C)
- Contact (Contact person for B2B, empty for B2C)
- Phone No., E-Mail, Address, City, Post Code, County
- Country/Region Code
Ship-to Address Table
Links customer to multiple delivery addresses
Country/Region Table
Maps ISO2 codes to BC country codes Example: US (ISO2) -> US (BC Code)
7. Key BigCommerce Extension Tables
CustomerSXE
Stores BigCommerce customer data
- Email: Used for Strategy 4 search
- Phone: Used for Strategy 5 search
- Company: Used for Strategy 6 search
- FirstName+LastName: Used to create BC customer name
CustomerAddressSXE
Stores BigCommerce customer addresses
- CountryCode (ISO2): Mapped to Country/Region
- Address fields: Used for Bill-To matching
- CustomerSystemId: Links to BC Customer
CustomerTemplateSXE
Stores customer templates by country and type
- CountryRegionCode: Filter by country
- CustomerType: B2B or B2C
- SourceType: How to create (use existing or create new)
8. Example: Real Order Processing
Order from BigCommerce Customer ID 98765
STEP 1: Check Order Type
- CompanyIdSXE > 0? NO
- CustomerId = 0? NO
- Path: Registered Customer
STEP 2: Get/Import Data
- Fetch CustomerSXE
- Found: john@acme.com, Acme Corp, +1-555-1234
- No prior BC link
STEP 3: Search (7 Strategies)
- Strategy 1-3: No match
- Strategy 4 (Email): john@acme.com matches CUST-001
- FOUND! Stop here
STEP 4: Assign Order
- SellToCustomerNo = CUST-001
- BillToCustomerNo = CUST-001
STEP 5: Ready for Processing!
9. Code Locations (For Developers)
| Process | Location |
|---|---|
| Entry point | OrderMappingMgt.Codeunit.al:28 |
| Sell-To mapping | OrderMappingMgt.Codeunit.al:58 |
| Guest customer | CustomerMappingMgt.Codeunit.al:45 |
| 7-Strategy search | CustomerMappingMgt.Codeunit.al:96 |
| Strategy 1 (Metafields) | CustomerMappingMgt.Codeunit.al:142 |
| Strategy 2 (Attributes) | CustomerMappingMgt.Codeunit.al:207 |
| Strategy 3 (Form Fields) | CustomerMappingMgt.Codeunit.al:266 |
| Strategy 4 (Email) | CustomerMappingMgt.Codeunit.al:328 |
| Strategy 5 (Phone) | CustomerMappingMgt.Codeunit.al:359 |
| Strategy 6 (Company) | CustomerMappingMgt.Codeunit.al:390 |
| Strategy 7 (Template) | CustomerMappingMgt.Codeunit.al:422 |
| Create customer | CustomerMappingMgt.Codeunit.al:475 |
| Bill-To mapping | OrderMappingMgt.Codeunit.al:111 |
End of Document
This mapping schema explains how BigCommerce customers are linked to or created as Business Central customers during order import.