Skip to content

Instantly share code, notes, and snippets.

@jungleeforce
Created November 11, 2021 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jungleeforce/5cce13484d06370460c7d3bad37e5b52 to your computer and use it in GitHub Desktop.
Save jungleeforce/5cce13484d06370460c7d3bad37e5b52 to your computer and use it in GitHub Desktop.
Publishing an event
const dataToPublish = {
Some_Text_Field__c: { string: "Test" },
Another_Boolean_Field__c: { boolean: false },
CreatedDate: new Date().getTime(), //This is Required
CreatedById: "0057X000003ilJfQAI", //Id of the current user. This is required.
};
client.Publish(
{
topicName: "/event/Your_Custom_Event__e",
events: [
{
id: "124",// this can be any string
schemaId: schemaId, //This is the same schemaId that we retrieved earlier.
payload: schema.toBuffer(dataToPublish), //The schema here is the avro generated schema
},
],
},
function (err, response) {
if (err) {
console.log("error from publishing ", err);
} else {
console.log("Response ", response);
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment