Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views5 pages

TSC Ask Lightning Web Components Scenario-Based Ans

Uploaded by

raj yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

TSC Ask Lightning Web Components Scenario-Based Ans

Uploaded by

raj yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

You need to create a real-time notification

component that displays updates


whenever Aplatform event is published in
Salesforce

ANS :-
Creating a real-time notification component for
Salesforce Platform Events involves several steps.
Step 1: Define the Platform Event
1. Navigate to Setup:
• Go to Salesforce Setup.
• In the Quick Find box, type Platform Events.
2. Create a New Platform Event:
• Click on New Platform Event.
• Definethe Name and API Name (e.g., Notification__e).
• Add custom fields as needed (e.g., Message__c, Type__c).
3. Save the Platform Event.

Vaibhav R Ghanokar.
Step 2 : Publish Events form Apex
1. Create an Apex Class:

This class will publish events to the Platform Event you created

2.Invoke the Publisher:


• You can call this method from other Apex classes, triggers, or even from
your LWC to publish notifications

Vaibhav R Ghanokar.
Step 3: Create the Lightning Web Component (LWC)
1. LWC JavaScript File:
• Use the lightning/empApi module to subscribe to the
Platform Event.

Vaibhav R Ghanokar.
2.LWC HTML Template:
• Display the notifications in your component.

Step 4: Deploy and Test


1. Deploy the Apex Class and LWC:
• Ensure both the Apex class and LWC are deployed to your
Salesforce org.
2. Add the LWC to a Lightning Page:
• Go to the Lightning App Builder and add your LWC to a page.
3. Test the Notification System:
• Trigger the publishNotification method from the Developer
Console or another part of your application to see real-time
notifications appear in your LWC.

Vaibhav R Ghanokar.
Vaibhav R Ghanokar.

You might also like