[SalesForce] updating field to null with UpdateSingleSalesforceObject AMPscript function

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.

  1. Create a workflow in Salesforce ORG to set email to null when a specific value is assigned.

  2. Modify AMPScript code to assign a dummy value in scenarios where email should be null.


Screenshot of custom workflow in Sales Cloud:


enter image description here


AMPscript example:

%%[  
 UpdateSingleSalesforceObject('Contact',@personid,'Email','delete@email.co')
]%%
Related Topic