Send Message

ltng:sendMessage

Sends some data (String or JSON) to other components within the application.

For Use In

Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App

::::::tabset{tabs='[ "Develop", "Specifications"]'}

:::::tab

Fire this event when you want to send a message to another component. To send a message, specify a string of text that you want to pass between components. Optionally, specify a channel for this event so that your components can select if they want to listen to particular event messages Using a channel is useful if you want to put multiple components on a page and you want to separate them into channels to prevent conflicts.

sendMsg: function(component, event) {
 var sendMsgEvent = $A.get("e.ltng:sendMessage");
 sendMsgEvent.setParams({
          "message": "Hello World",
          "channel": "AccountsChannel"
 });
 sendMsgEvent.fire();
}

:::::

:::::tab

Attributes

Name Description Type Default Required
channel Represents the channel name. Use a channel to enable a component to filter down to specific events. string
message A message in the form of a String or JSON. string Yes

:::::

::::::