1) When coding AMPScript in your messages or CloudPages, the Salesforce AMPscript functions CreateSalesforceObject and UpdateSingleSalesforceObject are executed when you preview your page or message.
This can result in duplicate records getting created or updated the existing record(s) in your integrated Sales and Service Cloud.
This will also affect previewing messages in Distributed Marketing.
2) This issue can arise when the same code is added to the text version of the email, causing the code to execute twice, once in the html version and once in the text version. As a result, duplicate records may be created in Sales/Service Cloud since the ampscript is executed twoce
1. If you wish to prevent these functions from executing in your preview, you can use the following IF condition to check the _messagecontext and only execute your CreateSalesforceObject or UpdateSingleSalesforceObject when the context is not in preview.
%%[ IF _messagecontext != 'PREVIEW' THEN ]%% !<--Add your CreateSalesforceObject/UpdateSingleSalesforceObject function call here. This code will not get executed in Preview. --> %%[ ENDIF ]%%
2. Remove code from the text verison of the email by click on the text version and removing the ampscript code in question. This will disable the syncing of the HTML changes to the TEXT version.
See the Personalization Strings in Email Studio documentation for more details on the _messagecontext string and its possible values.
000389734

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.