Order item 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_Item_Mapping Label: [MoveData] Commerce: Order Item - Mapping Type: Auto-Launched Flow Template API version: 56.0 Status: Active
This flow manages the transformation of commerce order item data from external platforms into Salesforce OpportunityLineItem records, handling price book entry relationships, pricing logic, and configurable fee handling.
Purpose#
The flow processes incoming order item data and maps it to appropriate Salesforce fields while managing:
- Fee type filtering with configurable exclusion of platform fees
- Currency determination for multi-currency environments
- Price book entry lookup and assignment for product relationships with enhanced error handling
- Opportunity relationship management for order items
- Pricing logic with support for both unit price and total price models
- Platform key assignment for external system tracking
- Quantity and pricing calculations
Salesforce fields#
| Object | Field API name | Field type | Purpose in flow |
|---|---|---|---|
| OpportunityLineItem | Id | ID | Primary record identifier |
| OpportunityId | Master-Detail to Opportunity | Links line item to parent order | |
| PricebookEntryId | Lookup to PricebookEntry | Product pricing relationship | |
| Quantity | Number | Item quantity | |
| UnitPrice | Currency | Price per unit | |
| TotalPrice | Currency | Total line item price | |
| md_comm_pack__Platform_Key__c | Text | External platform identifier | |
| Product2 | Id | ID | Product record identifier |
| Opportunity | Id | ID | Order record identifier |
| PricebookEntry | Id | ID | Price book entry identifier |
| Product2Id | Lookup to Product2 | Product relationship | |
| Pricebook2Id | Lookup to Pricebook2 | Price book relationship |
Input variables#
Core order item data#
| Variable | Type | Required | Description |
|---|---|---|---|
Record |
OpportunityLineItem SObject | Yes | The OpportunityLineItem record being processed |
Catalog_Type |
String | No | Item type for fee filtering |
Quantity |
Number | No | Order item quantity |
UnitPrice |
Currency | No | Price per unit |
Total |
Currency | No | Total line item price |
OrderTotal |
Currency | No | Total order amount |
PlatformKey |
String | No | Unique platform key for record matching |
OrderCurrencyType |
String | No | Currency code for order |
Related records#
| Variable | Type | Description |
|---|---|---|
CatalogRecord |
Product2 SObject | Associated product |
OrderRecord |
Opportunity SObject | Associated order/opportunity |
Platform integration#
| Variable | Type | Description |
|---|---|---|
StandardPriceBookId |
String | Standard price book ID |
PriceBookEntryId |
String | Price book entry ID |
Configuration variables#
| Variable | Type | Default | Description |
|---|---|---|---|
Config_OrderTotalSubtractFeePlatform |
Boolean | false | Exclude platform fee items from processing |
Output variables#
| Variable | Type | Description |
|---|---|---|
Record |
OpportunityLineItem SObject | Updated line item record |
Continue |
Boolean | Flag indicating processing continuation |
Errors |
String Collection | Error messages from processing |
Flow logic#
1. Pre-processing validation#
Fee type filtering:
- Checks if item type is "fee" and
Config_OrderTotalSubtractFeePlatformis true - Sets Continue flag and skips processing for excluded fee items
- Allows configurable exclusion of platform fee line items
2. Product relationship management#
Product assignment:
- Proceeds only if CatalogRecord (Product2) is provided
- Ensures proper product relationship for line item creation
Currency determination:
- Uses
CurrencyCodeComponentto determine appropriate currency - Processes
OrderCurrencyTypeinput to standardise currency handling - Supports multi-currency organisations
Price book entry lookup:
- Uses
GetPriceBookEntryFlowComponentwith currency support - Passes CurrencyCode, Pricebook2Id, and Product2Id parameters
- Enhanced error handling for missing price book entries
- Sets PricebookEntryId on the line item record when found
- Adds error to Errors collection if price book entry not found
3. Opportunity relationship processing#
Order assignment:
- Sets OpportunityId when OrderRecord is provided
- Links line item to parent opportunity/order
- Maintains order-item relationship structure
4. Pricing logic processing#
The flow handles two distinct pricing models:
Unit price model#
Condition: UnitPrice is provided and not null
- Sets Quantity field from input
- Sets UnitPrice field from input
- Allows Salesforce to calculate TotalPrice automatically
Total price model#
Condition: Total is provided and not null
- Sets Quantity field from input
- Sets TotalPrice field from input
- Allows Salesforce to calculate UnitPrice automatically
Default behaviour:
- If neither UnitPrice nor Total is provided, proceeds without price assignment
- Maintains flexibility for different pricing scenarios
5. Platform key assignment#
- Sets
md_comm_pack__Platform_Key__cfield with provided platform key - Enables future matching and duplicate detection
- Supports external system integration
Error handling#
Missing data scenarios#
- No product: Flow skips price book entry lookup and proceeds to opportunity assignment
- No price book entry: Flow adds error message to
Errorscollection instead of failing - No opportunity: Flow proceeds without setting OpportunityId
- Fee items: Flow can skip processing based on configuration settings
Data quality validation#
- Null values: Graceful handling of missing optional parameters
- Pricing flexibility: Supports different pricing models from external platforms
- Relationship integrity: Ensures proper product-price book relationships
- Currency handling: Processes multi-currency scenarios through dedicated components
- Error collection: Accumulates errors for batch reporting instead of failing immediately
Dependencies#
movedata__CurrencyCodeComponent(Apex action)GetPriceBookEntryFlowComponent(Apex action)