I've just moved some logic from one LWC into a "headless" @api invoke()
LWC that is configured as an Action that appears as a button in the standard "Highlights Panel" LWC. The method is called, but the LMS message does not make it to the subscribing components.
This documentation says:
... you can take advantage of all of the great services provided in the LWC framework. For example you can use Lightning Data Services to get data from Salesforce, you can use Apex to perform complex operations and you can use Lightning Navigation Service to navigate to other pages in Salesforce.
and this documentation
... communicate across the DOM between Visualforce pages, Aura components, and Lightning web components, including components in a pop-out utility bar.
Reading this Define the Scope of the Message Service hasn't answered this question for me, and no joy Googling so far. Oh and the description of APPLICATION_SCOPE
there isn't clear for me.
Some debugging revealed (first value is messageContext
, second value is messageChannel__default['default']
):
// For the action LWC publish
Symbol(MessageContext_597a18b7_ed66_43b1_bef1_04a6d1ba2b36)
81c785fd_958c_4725_b81f_4c3ac302b7a3
// For a component in the flexi-page body publish
Symbol(MessageContext_0aeda8b3_b4aa_4ad6_a926_78c3ac1736ce)
81c785fd_958c_4725_b81f_4c3ac302b7a3
// For a second component in the flexi-page body publish
Symbol(MessageContext_a3db5e30_9587_4d75_a447_52709b626c0e)
81c785fd_958c_4725_b81f_4c3ac302b7a3
so no obvious difference there.
I assumed that LMS should work in this context and the problem is something I've messed up on. But now I'm not so sure. Can anyone confirm?