0

I had followed this trailheadand the github code. Successfully apply to one of my org, but when I'm trying to copy to the another org, somehow it's not working. I had adjust the variety of cloudpage ID, subscriberkey and email. But, when I send an email to myself and click the cloudpage link, I'm not able to successfully log in my subscribe data.

<div style="display:none;">
  %%[
   SET @SubscriberKey = [_subscriberkey]
   SET @EmailAddress = [emailaddr]


      IF EMPTY(@SubscriberKey) OR EMPTY(@EmailAddress) THEN
          SET @error = true

      ELSE

          SET @preferenceCenterLink = CloudPagesURL(3490)
          SET @Status = 'Unsubscribed'
          SET @results = UpsertData('MBPassUnsubscribeList',2, 'EmailAddress', @EmailAddress, 'SubscriberKey', @EmailAddress, 'EDMStatus', @Status, 'ModifiedDate', Now())


          SET @vv1 = CreateObject("RetrieveRequest")
          SetObjectProperty(@vv1, "ObjectType", "Subscriber")
          AddObjectArrayItem(@vv1,"Properties","SubscriberKey")
          AddObjectArrayItem(@vv1,"Properties","EmailAddress")
          AddObjectArrayItem(@vv1,"Properties","Status")

          SET @mbv2 = CreateObject("SimpleFilterPart")
          SetObjectProperty(@mbv2, "Property", "SubscriberKey")
          SetObjectProperty(@mbv2, "SimpleOperator", "equals")
          AddObjectArrayItem(@mbv2, "Value",@SubscriberKey)
          SetObjectProperty(@mbv2, "Filter", @mbv2)
          SET @ResultSet = InvokeRetrieve(@mbv2)

          IF Rowcount(@ResultSet) == 1 THEN
              SET @row = ROW(@ResultSet,1)
              IF Field(@row,"Status") != @Status THEN
                  SET @sub = CreateObject("Subscriber")
                  SetObjectProperty(@sub,"EmailAddress", @EmailAddress)
                  SetObjectProperty(@sub,"SubscriberKey", @SubscriberKey)
                  SetObjectProperty(@sub,"Status",@Status)
                  SET @options = CreateObject("UpdateOptions")
                  SET @save = CreateObject("SaveOption")
                  SetObjectProperty(@save,"SaveAction","UpdateAdd")
                  SetObjectProperty(@save,"PropertyName","*")
                  AddObjectArrayItem(@options,"SaveOptions", @save)
                  SET @update_sub = InvokeUpdate(@sub, @update_sub_status, @update_sub_errorcode, @options)
              ENDIF
          ENDIF

      ENDIF
]%%
</div>

<div class="content-wrapper">
  <div class="pref-block-noborder form-wrapper-noborder">
    %%[@SubscriberKey]%%
    %%[@EmailAddress]%% 
    %%[ IF @error THEN ]%%
    <div class="pref-block-noborder form-wrapper-noborder">
      <p class="slds-text-heading_small" style="font-size: 1.45rem"> Error </p>
    </div>

    %%[ ELSE ]%%

    <div class="pref-block-noborder form-wrapper-noborder">
      <p class="slds-text-heading_small" style="font-size: 1.45rem">
        Thank you!You had successfully unsubscribe.
      </p>
    </div>
    %%[ ENDIF ]%%
  </div>
</div>
  • SSL is working.

Hope there's anyone can give me some hint.

Thanks a lot!

Best, Victoria

8
  • 1
    Custom code does NOT work just by copy n pasting, you may have to make necessary adjustments. Ex: you need to update CloudPage ID and DE names... CloudPagesURL(3490) ... MBPassUnsubscribeList is valid and relevant DE. Commented Feb 13, 2023 at 9:38
  • 1
    What exactly isn’t working, are you getting a 500 error or something else? I’d recommend wrapping your whole script in a try/catch to be able to troubleshoot it better (sfmarketing.cloud/2019/08/09/debugging-ampscript)
    – zuzannamj
    Commented Feb 13, 2023 at 10:16
  • Hello Vishal, we did adjust those variety as cloudpage ID and DE name, and created a DE for the same name and attribute...
    – Vee WANG
    Commented Feb 14, 2023 at 3:18
  • Hello zuzannamj, seems that we had right amp script, but somehow the page not able to catch the subscriberkey and email that not able to successfully unsubscribe.
    – Vee WANG
    Commented Feb 14, 2023 at 3:19
  • [update]When we set true data ( Subscriberkey & Email )to the code, it works. Therefore it means that the variety written way is wrong that not sure how to make it right? Shall we need to embed the variety in the link as well? Many Thanks.
    – Vee WANG
    Commented Feb 14, 2023 at 6:40

1 Answer 1

0

[Final update]The code is correct. When sending those email, remember to set the link as cloudpageID, not the cloudpage link.

You must log in to answer this question.

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