How to create a LightningMessageChannel using VS Code?
1. Open VS Code.
2. Create a Folder with the name "messageChannels" under force-app\main\default.
3. Create a file with Channel name followed by suffix ".messageChannel-meta.xml".
4. Add the below content(Change the variable names and add/remove as needed).
Sample Code:
<?xml version="1.0" encoding="UTF-8"?>
<LightningMessageChannel xmlns="http://soap.sforce.com/2006/04/metadata">
<masterLabel>SampleChannel</masterLabel>
<isExposed>true</isExposed>
<description>This is a sample Lightning Message Channel.</description>
<lightningMessageFields>
<fieldName>variable1</fieldName>
<description>Variable 1</description>
</lightningMessageFields>
<lightningMessageFields>
<fieldName>variable2</fieldName>
<description>Variable 2</description>
</lightningMessageFields>
</LightningMessageChannel>
5. Add the below in your package.xml.
<types>
<members>*</members>
<name>LightningMessageChannel</name>
</types>
Follow Us