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
- Sales Rep will be in Salesforce System
- Discount Details are available in a different Database
- The customer will be sitting on the Salesforce Digital Experience Site
- Sales Reps must need an Interface where they can enter Customer Identifier and Location to check the discount availability.
- 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
- Use JWT to connect with MuleSoft
- 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
- Create a Lightning Web Component to have the required input
- Publish the Platform Event using LWC
- Listen to the same event in MuleSoft, then make a Query to the database and publish the event from MuleSoft
- LWC will listen to the Event and display the message
- 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
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