Hello,
I'm developing my first PCF control for Dynamics 365 CE but i'm curious how to communicate with it from an form script.
I'll have a OnChange script with the following:
function testArjan(executionContext) {
window.postMessage({
messageName: "TestArjan",
}, window.location.href);
console.log(window.location.href);
}
In my PCF typescript i have an event listener:
constructor() {
window.addEventListener("message", this.handlePostMessage.bind(this), false);
}
private handlePostMessage(event: MessageEvent): void {
if (event.data) {
console.log(event.data); // hier krijgen we straks verzoeken binnen om nieuwe artikel regels toe te voegen vanuit de catalogus.
}
}
But i don't receive any messages. What am i doing wrong? Can someone give me an example how to communicate with my PCFControl from a OnChange form script.
Thanks :)!