I created an ampscript on a Landing page that should update Salesforce boolean fields and also suppress the current value of a specific text field (so that we get an empty value). The URL of the Landing Page is integrated on a email, and the SubscriberKey is embedded in the url. Example: http://sfmc-landingpage.com?c=%%_subscriberkey%%

Here is the ampscript :

SET     @ContactID  = QUERYPARAMETER('c')
SET     @AccountID = Lookup ("ENT.Contact_Salesforce", "AccountId", "_ContactKey",  @ContactID)
IF      @ContactID != "" THEN
        SET @ContactOptout1 = UpdateSingleSalesforceObject("Contact",@ContactID,"Optin_A__c","false")
            SET @ContactOptout2 = UpdateSingleSalesforceObject("Contact",@ContactID,"Optin_B__c","false")
                SET @ContactOptout3 = UpdateSingleSalesforceObject("Account",@AccountID,"ID_Company__c", " ")               

I tested in the Preview and Test steps of an Email with a specific contact, and after a click on the url, it worked fine, the boolean and text fields were updated as we wanted.

However, when I tried with a real send, the boolean fields were updated, but not the text field. The value has not been replaced by "empty". The client use PersonAccount. The boolean fields are on the Contact object and the Text field is on the Account object.

Would you have any idea of why it did not work on a real send (but it worked with Preview and Test)? Is the syntax for an empty field OK on the ampscript ? If not, how would be the right syntax? (I added a space between the quote for "empty")

Thank you



1 Answer 1


I'd probably write it like this, adding debugging output to determine the cause. If you get an error, I'd comment out all but the first Salesforce object functions and see what you get in the output.


set @ContactID  = QueryParameter('c')

set @contactRows = RetrieveSalesforceObjects(
        ,"id", "=", @ContactID

set @contactRowCount = rowcount(@contactRows)
output(concat("<br>contactRowcount: ", @contactRowCount))

if @contactRowCount > 0 then 

    set @contactRow = Row(@contactRows, 1)
    set @AccountId = Field(@contactRow, "AccountId")
    set @email = Field(@contactRow, "Email")

    output(concat("<br>AccountId: ", @AccountId))
    output(concat("<br>email: ", @email))

    set @falseVal = false

    set @updateContact = UpdateSingleSalesforceObject(
          "Contact", @ContactID
          , "Optin_A__c", @falseVal
          , "Optin_B__c", @falseVal
    set @updateAccount = UpdateSingleSalesforceObject(
          "Account", @AccountId
          , "ID_Company__c", ""

    output(concat("<br>updateContact: ", @updateContact))
    output(concat("<br>updateAccount: ", @updateAccount))



Also, it's not the best practice to pass around the subscriber key in the URL. The CloudPagesURL() function allows you to pass encrypted parameters that you can retrieve from the URL using the AttributeValue() function. I'd use that instead of QueryParameter().


  • Hello, Thank you very much for your help and recommendations. Here is the output I got : contactRowcount: 1 AccountId: 0011i00000JQzfdAAD email: [email protected] updateContact: 1 updateAccount: 1 - the boolean fields on Contact have been updated, but not the text field on Account. It seems that the "empty" value or suppressing a value is complicated to get ?
    – Ludivine L
    Commented Sep 4, 2019 at 9:08
  • If you want to set the field to null, any option is outlined here in this fine answer: salesforce.stackexchange.com/a/208206/5202 Commented Sep 4, 2019 at 11:59
  • Thank you very much for your help. In the meantime, I added a space between the quote for "empty" and it seems to work, even on an email send: set@updateAccount = UpdateSingleSalesforceObject( "Account",@AccountId , "ID_Company__c", " " I will try the 'fieldsToNull' next time. Thank you again!
    – Ludivine L
    Commented Sep 4, 2019 at 13:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .