2

I have a backbone of code where I am passing subscriber key to a landing page from an email. I want that when a subscriber clicks and is redirected to the page to update 2 records in salesforce.

I am able to pass the info of Subscriber Key in the URL & I am able to do the RetrieveSalesforceObjects but not the UpdateSingleSalesforceObject. I dont know what I am missing.

Below is the code from my page & info populated when redirect link from email is clicked:

%%[ var @SubscriberKey, @SalesforceID,@AccountIsFound, @ContactIsFound, @Proceed, @Certification,@Known, @updateRecord, @valueCert, @valueKnown

     /* Get parameters passed through the URL */

    SET @SubscriberKey = QueryParameter("SubscriberKey")
    SET @SalesforceID = Substring(@SubscriberKey, 0, 15)
    SET @AccountIsFound = "False"
    SET @ContactIsFound = "False"
    SET @Proceed = "True"


    /* Get Account information using the contact ID */

    SET @AccountRowset = RetrieveSalesforceObjects("Account", "Id, PersonEmail, PersonContactId, Certification__pc, Known_As__pc",
              "PersonContactId", "=", @SalesforceID)
     /* If it finds an account, get data from it */
    IF RowCount(@AccountRowset) > 0 THEN
                SET @AccountIsFound = "True"
                SET @AccountRow = Row(@AccountRowset,1)
                SET @AccountID = FIELD(@AccountRow, "Id")
        SET @Email = FIELD(@AccountRow, "PersonEmail")
                SET @Certification=FIELD(@AccountRow,"Certification__pc")
                SET @Known=FIELD(@AccountRow,"Known_As__pc")

    ELSE
      SET @Proceed = "False"
      InsertDE("Preference Centre Error Log", "SubscriberKey", @SubscriberKey,
                                                "Custom Message", "Account Not Found",
                                                "Status Message", "ERROR",
                                                "Error Date", NOW())
    ENDIF
SET @valueCert='BOZI'
SET @valueKnown='GDPR'
set @updateRecord=UpdateSingleSalesforceObject("Account",@Id,"Certification__pc",@valueCert,"Known_As__pc",@valueKnown)
]%%
<br>
18 char Contact ID: %%=v(@SubscriberKey)=%%
<br>
15 char Contact ID: %%=v(@SalesforceID)=%%
<br>
%%=v(@AccountRowset)=%%
<br>
Email from Account : %%=v(@Email)=%%
<br>
Certification: %%=v(@Certification)=%%
<br>
Known : %%=v(@Known)=%%
<br>
<html>
%%[if @updateRecord == 1 then]%%
         ﹤p﹥Record Updated﹤/p﹥
      %%[ elseif @updateRecord == 0 then]%%
        ﹤pUpdate Failed﹤/p﹥
%%[endif]%%
</html>

enter image description here

0

It looks like the problem might be because you are setting the UpdateSingleSalesforceObject as opposed to calling the function. Try removing the set @UpdateRecord

i.e.

UpdateSingleSalesforceObject("Account",@Id,"Certification__pc",@valueCert,"Known_As__pc",@valueKnown)
  • Thanks @Data_Kid. I tried to do that but no luck. I changed the code slightly to: SET @valueCert='BOZI' SET @valueKnown='GDPR' SET @updated=UpdateSingleSalesforceObject("Account",@Id,"Certification__pc",@valueCert,"Known_As__pc",@valueKnown) SET @Certification=FIELD(@updated,"Certification__pc") SET @Known=FIELD(@updated,"Known_As__pc") This time I got an error message related to the fact Error Message: Invalid object property name. Object Type: System.Int32 Property Name: Certification__pc – Giulietta May 3 '18 at 10:05
  • I'm not sure about this but some parts of your code use single quotes ('), and some does double quotes ("). Try changing SET @valueCert='BOZI' SET @valueKnown='GDPR' to double quotes – Mateusz Bartkowiak May 11 '18 at 14:37

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.