0

I have a journey that uses SF Data Entry and is triggered by ampscript in another email send writing to a field on a custom object in CRM.

It's simple, the entry criteria is that the CRM field text matches what it written to it by the email ampscript.

But, when I send a test email with the ampscript that updates the field, I get 2 entries into the journey although only one email was sent, the field was only updated once, there should only be one entry.

I can't set the journey settings to allow for one entry only as people may need to enter more than once.

What I'm hoping is anyone out there has experienced something similar or has a solution for handling duplicate entries via SF Data Entry trigger into a journey.

Thanks in advance!

1
  • did you send a MIME email, you ampscript executes in both html and text
    – EazyE
    Commented Dec 21, 2021 at 13:53

1 Answer 1

0

As EazyE commented, you are likely running into the "order of operations" (https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/orderOfOperations.html) behavior where multipart MIME emails execute AMPScript twice for each user, once in HTML, then in text.

As seen in the link, the email's code is processed in linear order, top to bottom, for each user. Variables are not reset between processing of the different versions, which is key for the approach further below.

You could just manipulate the text version to not mirror the html version (just write something else into it, which decouples both versions), but this is error prone as no-one ever thinks about the text version. Helps isolate the issue though.

To create code that counteracts this behavior:

Wrap each of the executions in a condition (e.g. I use executeNextOccurrence != false);

set that condition to "false" after the code you want to run only once.

So: At send time, the message will run your code once in HTML, then set the executeNextOccurrence condition to false .

It will then start executing the text version, with the executeNextOccurrence still being false (it is not reset between versions) --> your code is skipped after having been run once.

In another instance (i.e. you have to test with your specific code) I solved this the following way. I purposefully include the comment for posterity to understand what this is about.

%%[
IF _messagecontext == "SEND" AND jobid != 0 THEN
 
    IF @executeNextOccurrence != "false" THEN
        
        /* your code with outside effect here */

        

        /* if sendout is done using multipart MIME (which is basically always), 
        HTML is parsed, then text (https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/orderOfOperations.html),
        leading to AMPScript being interpreted twice. 
        The IF / ELSE / executeNextOccurrence workaround helps to prevent that 
        code "with outside effects" is run twice - once in HTML, once in text. 
        */

        SET @executeNextOccurrence = "false" 
    ENDIF
ENDIF
]%%
1
  • Thanks Jonas, your answer has been really helpful!
    – AnjLivi
    Commented Sep 17, 2022 at 22:14

You must log in to answer this question.

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