Loading

Duplicate Salesforce Objects created when using Salesforce Ampscript Functions in Marketing Cloud

Udgivelsesdato: Feb 18, 2025
Beskrivelse

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

Løsning

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.

Vidensartikelnummer

000389734

 
Indlæser
Salesforce Help | Article