Lightning Message Service (LMS)

Lightning Message Service (LMS) is generally available from Summer ’20 onwards, In this post & video to sharing how we can leverage it to communicate between Visualforce and Lightning Components (Aura & LWC) anywhere on a Lightning Page & utility bar. Lightning Message Service (LMS) is a standard publish-subscribe library […]

Lightning Message Service (LMS) is generally available from Summer ’20 onwards, In this post & video to sharing how we can leverage it to communicate between Visualforce and Lightning Components (Aura & LWC) anywhere on a Lightning Page & utility bar.

Lightning Message Service (LMS) is a standard publish-subscribe library in the UI, enabling components in any part of the DOM to communicate.

All interactions have to originate from the same Lightning Experience Application (Example Same browser tab).

Lightning message service is available in Lightning Experience only.

Lightning Message Service (LMS) is a simple API to publish messages throughout Lightning Experience and subscribe to messages that originated from anywhere within Lightning Experience.

Lightning Message Service is based on a new type of metadata called Lightning Message Channels. its a lightweight, packageable components.
Its represents a secure channel to communicate across Salesforce UI technologies i.e Visualforce and Lightning Components (AURA/LWC).
Lightning Message Service (LMS)
Lightning Message Service is based on a new metadata type: Lightning Message Channels.
  • In Visualforce, use to access from global variable $MessageChannel
  • In Aura, use to access from lightning:messageChannel
  • In LWC, use to access from Lightning Message Channel with the scoped module @salesforce/messageChannel

Create a Lightning Message Channel

  • Salesforce UI doesn’t support creating the message channel directly
  • Create LMC and deploy using ANT, Workbench or VS Code, or any IDE
  • Create a folder called “messageChannels” under force-app/main/default folder.
  • Create a file & structure should be MessageChannelName.messageChannel-meta.xml

<?xml version=”1.0″ encoding=”UTF-8″ ?>
<LightningMessageChannel xmlns=”http://soap.sforce.com/2006/04/metadata”>
<masterLabel>Account Message Channel</masterLabel>
<isExposed>true</isExposed>
<description>Message Channel to pass a Account Record Id</description>
<lightningMessageFields>
<fieldName>recordId</fieldName>
<description>This is the account Record Id</description>
</lightningMessageFields>
<lightningMessageFields>
<fieldName>recordData</fieldName>
<description>This is the account recordData</description>
</lightningMessageFields>
</LightningMessageChannel>

Demo

  • Demo – Lightning Message Service with VF Page
  • Demo – Lightning Message Service with AURA 
  • Demo – Lightning Message Service with LWC
  • Demo – Lightning Message Service with  b/w VF Page, AURA & LWC
  • Demo – Lightning Message Services with b/w VF Page, AURA & LWC (Utility-bar)

Session Video

Limitations/Consideration for LMS

  • LMS doesn’t currently support these Salesforce experiences and tools: Salesforce Mobile app, AppExchange, Lightning Out and Lightning Communities
  • LMS unsupported module for the LWC Local Development
  • Salesforce UI currently doesn’t support creating the message channel directly

Resources:

 

The post Lightning Message Service (LMS) appeared first on TheBlogReaders.com.

Balmon Hyper

Next Post

IKEA to improve intelligent technology solutions for customers

Mon Oct 19 , 2020
IKEA invests in nyris, a German deep-tech start-up company – to improve intelligent technology solutions for customers, partners and co-workers Inter IKEA Group has made a minority investment in nyris, a Germany-based innovative deep-tech start-up company, which provides visual intelligence technology. IKEA customers can already experience the nyris technology, in […]