salesforce-marketingcloud / blocksdk Goto Github PK
View Code? Open in Web Editor NEWPublic SDK for the Salesforce Marketing Cloud Content Builder
License: BSD 3-Clause "New" or "Revised" License
Public SDK for the Salesforce Marketing Cloud Content Builder
License: BSD 3-Clause "New" or "Revised" License
Hello, we are developing custom blocks in react for content builder and use your SDK to communicate between SFMC and our components.
I rewrote entirely the SDK in typescript as i needed the types to be able to use it correctly (it's the same class except i typed everything).
I'm having troubles when the SDK is initialized.
First we create the message event listener to get the messages from SFMC, then we send a handshake message from window.parent to ensure that the method is working properly and that the sender is effectively SFMC for security purpose.
Those methods are line 28 and 30 in https://github.com/salesforce-marketingcloud/blocksdk/blob/master/blocksdk.js
When i build my SDK class the first time, the handshake is sent, but not received by the _receiveMessage function (so _readyToPost is always false and pendingMessages are not sent, then i don't get my data from SFMC on init).
But if i hit the done editing button and come back on the custom block the handshake method is received and then i can get my data message from SFMC.
Have you got any leads about this ?
Thank you.
Is it possible for now to use BlockSDK and custom block in MarketingCloud?
I have implemented my own application:
This app works in blocktester
But
Does not in MarketingCloud.
In addition, I deployed the sampleblock to Heroku but I see the same issue:
It does not work in MarketingCloud.
After debugging and modifying the source code of SDK I found the issue. Parent window in MarketingCloud doesn't answer on handShake
.
In my local project, I have changed the code of SDK. And after that my custom block starts working in MarketingCloud.
this._postToEditor = function (payload, callback, ttl) {
var self = this;
- // we only message up if we have
- // validated the origin
- if (!this._parentOrigin) {
- if (ttl === undefined || ttl > 0) {
- window.setTimeout(function () {
- self._postToEditor(payload, callback, (ttl || 5) - 1);
- }, 20);
- }
- return;
- }
this._messages[this._messageId] = callback;
payload.id = this._messageId;
this._messageId += 1;
// the actual postMessage always uses
// the validated origin
- window.parent.postMessage(payload, this._parentOrigin);
+ window.parent.postMessage(payload, '*');
};
Hi, is there any way to catch the 'Done Editing' button to be able to run some validation on the inputs the user has filled. Thanks for your help.
Craig
Would it be possible to include a folder with a super simple sample project? This would help devs to see the API in action.
Thanks!
After Salesforce forced all subdomains to be tenant specific, line 227 needs to be updated to include 'sfmc-content\.com'
Our implementation broke until we added this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.