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)


However, I can't figure out how to update this to a null value. I have tried:




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?


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:

  • Thanks David, I was thinking of exactly the same solution. It looks like this is the only feasible workaround. I could create a Connected App and make a Salesforce REST API request in AMPscript, but that's not a good idea for a few different reasons. – Eliot Harper Dec 21 '16 at 21:10
  • And this workaround works perfectly, BTW! – Eliot Harper Dec 22 '16 at 6:11

The function does allow fieldsToNull, although not very well documented. The following code should work.

UpdateSingleSalesforceObject('Contact', @personid, 'fieldsToNull', 'Email')
  • You have your parameters backwards, it should be field to update then value to update. Also, using 'fieldsToNull' just sets the value to 'fieldsToNull'. – victorcorey Apr 4 '18 at 17:38
  • @victorcorey not in the case of using the 'fieldsToNull' parameter. You are correct when that parameter is not being used. When the parameter is used, the logic is backward. The value truly gets set to an empty value. – Steve J Apr 5 '18 at 18:55
  • 1
    Confirmed that this works. If you have multiple fields to update, you need to make several calls, but it works. This should be the selected answer. – David Murphy Dec 17 '19 at 2:18
  • Also confirmed that this works on a multi-select picklist. – Jackson Chen Jan 24 '20 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.