UpdateSingleSalesforceObject Function

The UpdateSingleSalesforceObject function allows you to update a record in an object in Salesforce (both standard and custom objects). You need to have the connector enabled and configured correctly in order for this AMPscript function to work. You do not need to have the object synced via Synchronized Data Extensions.

Additional fields and value pairs can be used as part of an AND clause in the function.



1 = Salesforce Object: Account, Contact, Lead, Opportunity (or custom object)
2 = Id of the record to update
3 = Field name to update within the same object (1)
4 = Value to update in the field (3)




var @id, @result
set @id = RequestParameter(“_subscriberkey”)
set @result = UpdateSingleSalesforceObject(‘Contact’,@id,’HasOptedOutOfEmail’,’true’)



None. (The Salesforce documentation for the UpdateSingleSalesforceObject function states that a 0 or 1 is returned for failure and success but I haven’t seen any values returned).


This is code in a CloudPage using CloudPagesURL function to send the _subscriberkey to the page.

The RequestParameter function takes the _subscriberkey that is passed to the CloudPage via the URL. I.e. AMPscript.com/landing-page?_subscriberkey=0033000000GvHJL

The UpdateSinglesSalesforceObject finds the record (0033000000GvHJL) on the Contact object and updates HasOptedOutofEmail to “true.”

Leave a Reply

Your email address will not be published. Required fields are marked *