I need to update the Email field in the Salesforce Contact Object to null.
If I use the following code, the email field in the Contact Object is updated to sam@sample.com
:
%%[
var @personid
set @personid = Lookup('Ent.All Services','PersonID','Id', _subscriberkey)
UpdateSingleSalesforceObject('Contact',@personid,'Email','sam@sample.com')
]%%
However, I can't figure out how to update this to a null value. I have tried:
UpdateSingleSalesforceObject('Contact',@personid,'Email',null)
And:
UpdateSingleSalesforceObject('Contact',@personid,'Email','')
But this does not update the email address.
I understand that the UpdateSingleSalesforceObject()
function is a wrapper for the Salesforce API and according to this documentation you need to include a fieldsToNull
array, but this is not an option in the AMPscript function.
Does anyone know a solution to this?
Best Answer
I understand your dilemma. I have a solution, albeit a total hack.
Create a workflow in Salesforce ORG to set email to null when a specific value is assigned.
Modify AMPScript code to assign a dummy value in scenarios where email should be null.
Screenshot of custom workflow in Sales Cloud:
AMPscript example: