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 start your AI Journey?

Table of Contents Introduction Are you tired of the same old world? Do you dream of painting landscapes with your code, composing symphonies with data, or...

The Secret Weapon: Prompt Engineering: 🪄

Table of Contents Introduction Crafting the perfect prompt is like whispering secret instructions to your AI muse. But there's no one-size-fits-all approach! Exploring different types of...

How to Singup for your own Production org?

Let's see how we can have our salesforce enterprise Salesforce Org for a 30-day Trial and use it as a Production environment. With the...

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