Quantcast
Channel: Active questions tagged ampscript - Salesforce Stack Exchange
Viewing all articles
Browse latest Browse all 359

AMPscript to update a Contact Record in Salesforce

$
0
0

I have a backbone of code where I am passing the 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 don't 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())    ENDIFSET @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


Viewing all articles
Browse latest Browse all 359

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>