I'm trying to use the lightning message service on a visualforce page.
To simplify things, I'm using the exact code supplied by Salesforce with the one exception I've updated the SAMPLEMC
variable to use my message channel.
Ref: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/message_channel_publish.htm
<apex:page >
<script>
// Load the MessageChannel token in a variable
var SAMPLEMC = "{!$MessageChannel.MY_NAMESPACE__Awesome_LMS__c}";
function handleClick() {
const payload = {
recordId: "some string",
recordData: {value: "some value"}
}
sforce.one.publish(SAMPLEMC, payload);
}
</script>
<div>
<p>Publish SampleMessageChannel</p>
<button onclick="handleClick()">Publish</button>
</div>
</apex:page>
When I click the button, I get the Uncaught ReferenceError: sforce is not defined
in the console:
This is similar to Lightning Messaging Service: sforce.one not defined however my VF page is not running in an iframe.
I've attempted this in both Classic and Lightning UI.
Any ideas what the problem is, and how to solve?