How to use LWC & Platform Event with MuleSoft?

on

|

views

and

comments

 

Hello #Trailblazer #Mules,

In this blog post we are going to talk The Power of MuleSoft + LWC with Platform Event

Scenario

SFDCPanther is the whole seller of the parts of the heavy vehicles and the customer can reach out to Sales Rep to check if they are eligible for a discount or not.

Key points to Remember

  1. Sales Rep will be in Salesforce System
  2. Discount Details are available in a different Database
  3. The customer will be sitting on the Salesforce Digital Experience Site
  4. Sales Reps must need an Interface where they can enter Customer Identifier and Location to check the discount availability.
  5. SFDCPanther is concern about the security while making the call to an external database

Solution

The Salesforce Architect at SFDCPanther suggested using MuleSoft & Platform Event along with the LWC Component to achieve the solution.

Solution Approach

  1. Use JWT to connect with MuleSoft
  2. Create 2 Platform Event one for Making a call to External System using MuleSoft and the other for Salesforce to listen to the response from MuleSoft
  3. Create a Lightning Web Component to have the required input
  4. Publish the Platform Event using LWC
  5. Listen to the same event in MuleSoft, then make a Query to the database and publish the event from MuleSoft
  6. LWC will listen to the Event and display the message
  7. Test It

Setup Component at Salesforce Side

Step1 – Create Connected Application – Follow this link to create a connected application that supports JWT for authentication

Step2 – Create Platform Events

Login to Salesforce Org then navigate to

Setup -> Integrations -> Platform Events and Create 2 platform events. Below are the screenshots for the reference

Pricing Event – Published from LWC
Discount Event – Published from MuleSoft

Step3 – Create Lightning Web Component

You can get the Complete Code for the Lightning Web Component and Apex Class from Here.

Setup MySQL

Download and Install the MySQL Workbench from Here.

Download and Install the MySQL Client from Here.

Setup MuleSoft Project

Watch the below video for MuleSoft Setup and explanation

Resources

  1. MuleSoft Blog
  2. JWT Authentication Salesforce
  3. Platform Event with MuleSoft
  4. Platform Event in Salesforce
Amit Singh
Amit Singhhttps://www.pantherschools.com/
Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion
Share this

Leave a review

Excellent

SUBSCRIBE-US

Book a 1:1 Call

Must-read

How to Utilize Salesforce CLI sf (v2)

The Salesforce CLI is not just a tool; it’s the cornerstone of development on the Salesforce Platform. It’s your go-to for building, testing, deploying, and more. As one of the most important development tools in our ecosystem

Save the day of a Developer with Apex Log Analyzer

Table of Contents What is Apex Log Analyzer? Apex Log Analyzer, a tool designed with Salesforce developers in mind, is here to simplify and accelerate your...

Salesforce PodCast

Introduction Hey Everyone, Welcome to my podcast, the first-ever podcast in India for Salesforce professionals. Achievement We are happy to announce that we have been selected as Top...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here

5/5

Stuck in coding limbo?

Our courses unlock your tech potential