1

We need to create a record in a Salesforce [Sales Cloud] Custom Object each time an email is sent from a Sent Email Activity in Journey Builder.

We've added an SSJS script in the email to retrieve an OAuth access token from Salesforce then make a POST request using the Salesforce REST API and the SSJS Post() function.

This is working well; when an email is sent, the record is created in Salesforce. However, we are seeing two records created each time an email is sent. It appears that the SSJS script is being executed twice by the Email send engine.

Has anyone else experienced this and is there a workaround?

1 Answer 1

3

There could be another scenario that would cause your script to fire again. Two come to mind:

  1. Text Version - Make sure you remove the SSJS from the text version of your email.

  2. Message Context - Wrap your SSJS in an AMPScript conditional that checks to make sure the _messageContext is "Send".

Out of curiosity, why do you need to do this? Does the Cloud Connector synchronization not cover your need for SFMC activity data in the Sales Cloud?

2
  • 1
    Thanks Adam, I didn't think about the text version. We removed the SSJS from the text version of the email and it works fine. Regarding your question. The Cloud Connector (v5 Connector) only allows you to is to import data from Salesforce. The new Data Stream feature is promising as this allows true synchronization, but this is still only updating near-time, not real-time, which is what we require for this specific project. Commented Mar 9, 2016 at 18:57
  • @EliotHarper, How do I remove from Text Version? I have the same issue
    – yoni349
    Commented Feb 23, 2021 at 8:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .