Back to insights
Salesforce IntegrationSalesforceMuleSoft

Salesforce B2C to Salesforce Core Integration Using MuleSoft and Platform Events

Build a scalable integration between Salesforce B2C Commerce and Salesforce Core using MuleSoft and Platform Events.

Nunmadhi Kodeshwaran13 min read

Salesforce Integration Developer

Salesforce B2C to Salesforce Core Integration Using MuleSoft and Platform Events cover infographic

Project Overview

The project involved integrating a B2C Commerce storefront with Salesforce Core using MuleSoft and Platform Events. The primary objective was to synchronize Products and Orders from the B2C platform into Salesforce Core in near real-time.

This integration ensured that product information and customer orders created in the B2C storefront were automatically processed and stored within Salesforce Core for downstream business operations.

Business Requirement

The client maintained their online storefront in Salesforce B2C Commerce.

Whenever:

  • A new product was created or updated
  • A customer placed an order

The data needed to be sent to Salesforce Core automatically.

The solution had to support:

  • Near real-time processing
  • High-volume transactions
  • Reliable error handling
  • Scalable architecture

High-Level Architecture

B2C Commerce
    ↓
MuleSoft
    ↓
Salesforce Platform Event
    ↓
Salesforce Core
    ↓
Product / Order Creation

Integration Flow

Step 1: Event Generated from B2C Commerce

When a product or order was created in the B2C storefront:

  • B2C generated the required payload.
  • Payload contained product or order information.
  • Data was sent to MuleSoft through REST APIs.

Example:

Data TypeFields
Product DataProduct ID, Product Name, SKU, Price, Inventory
Order DataOrder Number, Customer Information, Order Lines, Total Amount

Step 2: MuleSoft Processing

MuleSoft acted as the middleware layer.

Responsibilities:

  • Receive requests from B2C Commerce.
  • Validate incoming payloads.
  • Transform data into Salesforce format.
  • Apply business rules.
  • Handle errors and retries.

MuleSoft ensured the payload structure matched Salesforce Core requirements.

Step 3: Publish Platform Event

Instead of directly creating records in Salesforce, MuleSoft published a Platform Event.

Example Events:

  • Product_Sync_Event__e
  • Order_Sync_Event__e

Event Payload:

  • External ID
  • Product Details
  • Order Details
  • Status Information

Benefits:

  • Asynchronous processing
  • Better scalability
  • Reduced API limitations
  • Improved reliability

Step 4: Salesforce Core Event Subscription

Salesforce Core subscribed to Platform Events. Apex Triggers were configured on Platform Events.

Example:

  • Product_Sync_Event__e Trigger
  • Order_Sync_Event__e Trigger

Whenever an event was received:

  • Trigger processed the event.
  • Data validation was performed.
  • Business logic was executed.

Step 5: Product Creation in Salesforce

Product Event Processing:

  1. Receive Platform Event.
  2. Validate mandatory fields.
  3. Check if Product already exists.
  4. Create or Update Product2 record.
  5. Update Product Catalog information.
  6. Log processing status.

Objects Used:

  • Product2
  • PricebookEntry
  • Custom Logging Objects

Step 6: Order Creation in Salesforce

Order Event Processing:

  1. Receive Order Platform Event.
  2. Validate order data.
  3. Check duplicate orders using External ID.
  4. Create Account and Contact if required.
  5. Create Order record.
  6. Create Order Items.
  7. Update order status.
  8. Log success or failure.

Objects Used:

  • Account
  • Contact
  • Order
  • OrderItem

Error Handling

Error handling was implemented at multiple levels.

LayerError Handling Mechanisms
MuleSoftPayload validation, retry mechanism, error queue, logging
SalesforcePlatform Event error handling, Apex exception handling, custom error logs

This ensured failed transactions could be identified and reprocessed.

Benefits of Using Platform Events

  • Loose coupling between systems.
  • Asynchronous processing.
  • Better scalability.
  • Improved performance.
  • Reduced integration dependency.
  • Reliable event-driven architecture.

My Responsibilities

  • Developed Apex Triggers on Platform Events.
  • Created Product and Order processing logic.
  • Implemented validation and duplicate checks.
  • Handled error logging and exception management.
  • Worked with MuleSoft integration team.
  • Participated in deployment and testing activities.
  • Supported production issue analysis and fixes.

Key Salesforce Components Used

  • Platform Events
  • Apex Triggers
  • Product2
  • Order Management Objects
  • Custom Metadata
  • Custom Settings
  • Named Credentials
  • Integration Logging Framework
Topics:SalesforceMuleSoftPlatform Events

Ready to accelerate your digital transformation?

Partner with Subsel to build modern CRM, AI-enabled automation, and enterprise systems that scale.