Order mapping flow
Note
This flow is self-documenting and should be viewed within Salesforce (Setup > Process Automations > Flows). This document is to support working through a visual flow. The flow commentary in this document was generated with AI assistance.
Overview#
Flow name: MoveData_Commerce_Order_Mapping Label: [MoveData] Commerce: Order - Mapping Type: Auto-Launched Flow Template API version: 56.0 Status: Active
This flow maps and transforms commerce order data from external platforms into Salesforce NPSP-enabled Opportunity records. It processes orders with configurable offline order handling, price book management, and comprehensive fee tracking.
Purpose#
The flow processes incoming order data and maps it to appropriate Salesforce NPSP fields while handling:
- Order status processing with configurable offline order handling
- Customer relationship management (Contact/Account assignment)
- Price book assignment and validation
- Date conversions and close date management
- Fee tracking across multiple fee types (platform, gateway, taxes)
- Currency setting and NPSP field integration
- Order naming and description processing
Salesforce fields#
| Object | Field API name | Field type | Purpose in flow |
|---|---|---|---|
| Opportunity | Id | ID | Primary record identifier |
| Name | Text (120) | Order name | |
| StageName | Picklist | Order stage assignment | |
| CloseDate | Date | Transaction/completion date | |
| Description | Long Text Area | Order description | |
| AccountId | Lookup to Account | Associated account relationship | |
| CampaignId | Lookup to Campaign | Campaign association | |
| Pricebook2Id | Lookup to Pricebook2 | Price book assignment | |
| RecordTypeId | Lookup to RecordType | Order record type assignment | |
| CurrencyIsoCode | Picklist | Order currency | |
| npsp__Primary_Contact__c | Lookup to Contact | NPSP primary contact relationship | |
| movedata__Platform_Key__c | Text | External platform identifier | |
| md_npsp_pack__Fee__c | Currency | Aggregate processing fees | |
| md_npsp_pack__Gateway_Fee__c | Currency | Payment processor charges | |
| md_npsp_pack__Platform_Fee__c | Currency | Commerce platform charges | |
| md_npsp_pack__Tax__c | Currency | Overall tax amounts | |
| md_npsp_pack__Gateway_Fee_Tax__c | Currency | Tax on gateway charges | |
| md_npsp_pack__Platform_Fee_Tax__c | Currency | Tax on platform charges | |
| md_npsp_pack__Receipt_Number__c | Text (50) | Order receipt number | |
| Contact | Id | ID | Contact record identifier |
| AccountId | Lookup to Account | Account relationship resolution | |
| Account | Id | ID | Account record identifier |
| Campaign | Id | ID | Campaign record identifier |
Input variables#
Core order data#
| Variable | Type | Required | Description |
|---|---|---|---|
Record |
Opportunity SObject | Yes | The Opportunity record being processed |
OrderName |
String | No | Order name from external platform |
Status |
String | No | External platform status (offline/other) |
Description |
String | No | Order description |
ReceiptNumber |
String | No | External receipt or transaction number |
CreatedAt |
DateTime | No | Order/transaction date |
Code |
String | No | Order code identifier |
CurrencyType |
String | No | Currency code |
Processor |
String | No | Payment processor identifier |
Related records#
| Variable | Type | Description |
|---|---|---|
PrimaryContact |
Contact SObject | Primary contact for the order |
PrimaryAccount |
Account SObject | Associated account for the order |
PrimaryContactAlt |
Account SObject | Person Account alternative |
OrderCampaign |
Campaign SObject | Associated campaign |
Platform integration#
| Variable | Type | Description |
|---|---|---|
PlatformKey |
String | Unique platform key for record matching |
OrderRecordTypeId |
String | Record type ID for orders |
StandardPriceBookId |
String | Standard price book ID |
Fee structure#
| Variable | Type | Description |
|---|---|---|
Fee |
Currency | General fee amount |
FeePlatform |
Currency | Platform-specific processing fee |
FeeGateway |
Currency | Payment gateway processing fee |
Tax |
Currency | General tax amount |
TaxPlatform |
Currency | Tax on platform fees |
TaxGateway |
Currency | Tax on gateway fees |
Configuration variables#
| Variable | Type | Default | Description |
|---|---|---|---|
Config_OrderProcessOffline |
Boolean | false | Process offline orders |
Config_OrderSetDescription |
Boolean | true | Set description from message |
Config_OrderStageNameDefault |
String | "Prospecting" | Default stage name for orders |
Output variables#
| Variable | Type | Description |
|---|---|---|
Record |
Opportunity SObject | Updated opportunity record |
Cancel |
Boolean | Flag indicating processing cancellation |
Errors |
String[] | Collection of error messages |
Logs |
MoveDataLogEntry[] | Processing logs |
LogsJSON |
String | JSON representation of processing logs |
Flow logic#
1. Pre-processing validation#
Offline order handling:
- Checks if status equals "offline" and
Config_OrderProcessOfflineis false - Logs skip reason and sets Cancel flag to terminate processing
- Allows configurable processing of offline orders
2. Customer relationship management#
Customer priority resolution:
- Direct assignment: Uses provided PrimaryContact or PrimaryAccount
- Person Account support: Handles PrimaryContactAlt for Person Account scenarios
- Account resolution: Determines AccountId from contact relationship
- Account lookup: Queries contact record if AccountId not directly available
Account ID resolution logic:
- If PrimaryContactAlt exists (Person Account): Uses PrimaryContactAlt.Id
- If PrimaryAccount exists: Uses PrimaryAccount.Id
- If PrimaryContact has AccountId: Uses PrimaryContact.AccountId
- If neither: Looks up Contact record to get AccountId
3. Order name and price book processing#
New record processing:
- Sets order name using
OrderNameCalculatedformula for new records only - Formula:
IF(ISBLANK(OrderName), 'Temp Value', OrderName) - Prevents overwriting names on existing records
Price book assignment:
- Uses existing Pricebook2Id if already set
- Falls back to StandardPriceBookId if configured
- Logs error if no active Standard Price Book available
4. Date and currency processing#
Close date assignment:
- CreatedAt date: Converts CreatedAt to local date using
ConvertToLocalDateFlowComponent - Current date: Uses current date as fallback
Currency setting:
- Determines currency using
CurrencyCodeComponent - Only sets CurrencyIsoCode when a valid currency code is present (length > 0)
- Sets CurrencyIsoCode using
SetValueComponent - Ensures consistent currency handling across multi-currency orgs
5. Stage assignment#
- Preserves existing StageName if already set
- Uses
Config_OrderStageNameDefault("Prospecting") as fallback - Supports configurable default stage assignment
6. Contact and account assignment#
NPSP primary contact:
- Sets
npsp__Primary_Contact__cwhen PrimaryContact provided - Enables NPSP contact role and relationship processing
Account relationship:
- Sets AccountId from resolved PrimaryAccountId
- Maintains account-opportunity relationships
7. Fee processing#
The flow processes comprehensive fee structure using SetValueComponent:
| Fee field | Source variable | Description |
|---|---|---|
md_npsp_pack__Fee__c |
Fee |
General fee |
md_npsp_pack__Platform_Fee__c |
FeePlatform |
Platform fee |
md_npsp_pack__Gateway_Fee__c |
FeeGateway |
Gateway fee |
md_npsp_pack__Tax__c |
Tax |
General tax |
md_npsp_pack__Platform_Fee_Tax__c |
TaxPlatform |
Platform tax |
md_npsp_pack__Gateway_Fee_Tax__c |
TaxGateway |
Gateway tax |
Each fee type follows conditional assignment and only sets the field if the corresponding input variable is not null.
8. Description and campaign processing#
Description assignment:
- Sets Description field when provided and
Config_OrderSetDescriptionis true - Preserves existing descriptions when configuration disabled
Campaign association:
- Sets CampaignId when OrderCampaign provided
- Enables campaign attribution and reporting
9. Receipt number and record type#
Receipt number:
- Sets
md_npsp_pack__Receipt_Number__cwhen provided - Maintains external receipt tracking
Record type assignment:
- Sets RecordTypeId when OrderRecordTypeId provided
- Enables proper record type categorisation
10. Currency validation and platform key assignment#
Currency validation:
- Uses
CurrencyTypeLenformula to check for non-empty currency codes - Only sets CurrencyIsoCode when length > 0
Platform key processing:
- Sets
movedata__Platform_Key__cfor future matching - Enables duplicate detection and record updates
Error handling#
Comprehensive error tracking#
- Missing Standard Price Book
- Account resolution failures
- Currency conflicts
Detailed logging#
- Offline order skip reasons using
WriteToLogFlowComponent - Processing decision points
- Fee assignment tracking
Dependencies#
movedata__ConvertToLocalDateFlowComponent(Apex action)movedata__CurrencyCodeComponent(Apex action)movedata__SetValueComponent(Apex action)movedata__WriteToLogFlowComponent(Apex action)