Loading
Salesforce now sends email only from verified domains. Read More

How to update or insert (Upsert) with Salesforce Marketing Cloud connector

Publish Date: Mar 2, 2024
Task

GOAL

You have a list of objects to save in Salesforce Marketing Cloud. Some objects currently exist in SFMC and others are new. You need the firsts to be updated and the rest to be created.

The Upsert operation is throwing the error `SaveAction: UpdateAdd violation` 
Steps
Upsert doesn't apply because it won't update the record. Upsert operation is used to create an object only if it doesn't exist, or delete an existing object on the ExactTarget web server. This operation is achieved by using "Create" method of the ExactTarget SOAP API. (http://mulesoft.github.io/mule-salesforce-marketing-cloud-connector/1.1.0/functional/user-manual.html)

The correct approach here is to use the Update operation with updateOptions where the payload will be a list of API Objects:
  <dw:transform-message>
    <dw:set-variable variableName="UpdateOptions"><![CDATA[%dw 1.0
      %output application/java
      ---
      {
        saveoptions : {
          saveoption: [{ PropertyName: "*",SaveAction:"UPDATE_ADD" }]
      }
      }
    ]]>
    </dw:set-variable>
  </dw:transform-message>
  <sfdc-marketing-cloud:update config-ref="Salesforce_Marketing_Cloud__OAuth_Configuration" objectType="MyAPIObjectType" updateOptions-ref="#[flowVars.UpdateOptions]"/>

 
Knowledge Article Number

001114941

 
Loading
Salesforce Help | Article