Skip to content

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, processing price book entries, pricing logic, and opportunity associations.

Purpose#

The flow processes incoming order item data and maps it to Salesforce fields while handling:

  • Product relationship management through price book entries
  • Opportunity relationship assignment for order items
  • Flexible pricing logic with support for both unit price and total price models
  • Platform key assignment for external system tracking
  • Quantity and pricing calculations
  • Currency determination and multi-currency support
  • Fee skipping logic based on configuration settings
  • Error handling and reporting

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_npc_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
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
Catalog_Type String No Type of catalog item (e.g., "fee")
OrderCurrencyType String No Currency code for the order
Config_OrderTotalSubtractFeePlatform Boolean No Configuration to skip fee items
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

Output variables#

Variable Type Description
Record OpportunityLineItem SObject Updated line item record
Continue Boolean Whether to continue processing
Errors String Collection Collection of error messages

Flow logic#

1. Fee skipping logic#

The flow evaluates fee items based on configuration:

  • Checks if Config_OrderTotalSubtractFeePlatform is true
  • Evaluates if Catalog_Type equals "fee"
  • If both conditions are met, sets Continue to true and skips processing
  • Otherwise, proceeds to product relationship management

2. Product relationship management#

Product assignment:

  • Proceeds only if CatalogRecord (Product2) is provided
  • Ensures proper product relationship for line item creation

Currency determination:

  • Calls movedata__CurrencyCodeComponent Apex action to determine currency
  • Processes OrderCurrencyType input parameter
  • Returns standardised currency code for price book entry lookup

Price book entry retrieval:

  • Calls GetPriceBookEntryFlowComponent Apex action instead of direct SOQL lookup
  • Passes CurrencyCode, Pricebook2Id, and Product2Id parameters
  • Handles multi-currency scenarios through Apex component
  • Returns PricebookEntry record for assignment

Error handling:

  • Evaluates if PricebookEntry was found
  • If no entry found, adds error message to Errors collection: "Could not find a Pricebook Entry."
  • If found, sets PricebookEntryId on the line item record

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_npc_pack__Platform_Key__c field with provided platform key
  • Enables future matching and duplicate detection
  • Supports external system integration

Formulas#

Price book ID calculation#

Formula name: CalculatedPriceBookId Expression: StandardPriceBookId

Provides a standardised reference to the price book ID for consistent price book entry lookups.

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 Errors collection 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)
Ask MoveData AI
Ask about setup, configuration, or troubleshooting
How can I help you with MoveData today?