1

We're building a custom preference center. The target DE that needs to be updated is in this case also used as sendable DE for testing purposes. The DE contains the following columns: externalID(text & Primary Key), Optin (boolean), Rating (text) EmailAddress(EmailAddress),FirstName (text) ,LastName (text). The issue is that even though MC recongizes that a contact has opt-in true and allows him to pass his decision and get to the validation/thank you landing page, the optin record in the target DE does NOT get updated.

Here's the case: On the first custom preference page built in Web Studio landing page (via Content Builder), here's the ampscript code:

%%[
VAR  @externalID, @optin

set @externalID=RequestParameter('ExternalID')

set @rowsMaster=LookupRows("Test_DE_Company_and_Agency","ExternalID", @externalID)
IF RowCount(@rowsMaster)>0 THEN
SET @rowMaster=Row(@rowsMaster,1)
SET @Email=Field(@rowMaster,"EmailAddress")
ENDIF

SET @rows=LookupRows("Test_DE_Company_and_Agency","externalID", @externalID)
IF RowCount(@rows)>0 THEN
SET @row=Row(@rows,1)
SET @optin=Field(@row,"Optin")
ENDIF

]%%

In the html, we have

... the form tag:

              %%[IF @optin==1 THEN ]%%
                  <label>
                    <input id="Optin" name="Optin" type="checkbox" checked="true" value="Optin" onclick="CheckUnSubscribe()"> I wish to receive communications by email from Company.
                  </label>
                  %%[ELSE]%%
                  <label>
                    <input id="Optin" name="Optin" type="checkbox" value="Optin" onclick="CheckUnSubscribe()"> I wish to receive communications by email from Company
                  </label>
                  %%[ENDIF]%%
                </div>


                <div class="btn-wrapper">
                  <button class="btn btn-default button" type="submit">Save your Preferences</button>
                </div>
                <input type="hidden" name="ExternalID" value="%%=v(@externalID)=%%">
              </form>

On the second, confirmation page, we have the following Ampscript code:

%%[
  set @externalID=RequestParameter('ExternalID')
  set @checkboxO = RequestParameter('Optin')
  set @currentTime = Now()

set @rowsMaster=LookupRows("Test_DE_Company_and_Agency","ExternalID", @externalID)
IF RowCount(@rowsMaster)>0 THEN
SET @rowMaster=Row(@rowsMaster,1)
SET @Email=Field(@rowMaster,"EmailAddress")
ENDIF

SET @ll_sub = CreateObject("Subscriber")

SetObjectProperty(@ll_sub,"EmailAddress", @Email)
SetObjectProperty(@ll_sub,"SubscriberKey", @externalID)

SET @client = CreateObject("ClientID")
SetObjectProperty(@client, "ID", 100008022)
SetObjectProperty(@client, "IDSpecified", "true")
SetObjectProperty(@ll_sub, "Client", @client)

Set @options = CreateObject("UpdateOptions")
Set @save = CreateObject("SaveOption")
SetObjectProperty(@save,"SaveAction","UpdateAdd")
SetObjectProperty(@save,"PropertyName","Status")
AddObjectArrayItem(@options,"SaveOptions", @save)


IF @checkboxO=="Optin" THEN
set @checkboxOval=1

SetObjectProperty(@ll_sub,"Status", "Active")
ELSE set @checkboxOval=0

SetObjectProperty(@ll_sub,"Status", "Unsubscribed")
ENDIF

updateDE("Test_DE_Company_and_Agency",1,"ExternalID", @externalID, "Optin",@checkboxOval)
]%%

In the html we have the "thank-you" text and the form validation:

 <form action="%%=CloudPagesURL(1345)=%%" method="post">
4
  • I can't see that you have any handling if the ExternalId doesn't exist in the Test_DE_Company_and_Agency. Are you sure the ID is there? Aug 13, 2019 at 7:58
  • I get your point, but since we're using a DE with test data inside of it, then I can confirm the ID is in there.
    – nix9247
    Aug 13, 2019 at 8:02
  • Okay, I have a bit of a hard time following your code. Can you paste the full code for each page involved? Aug 13, 2019 at 8:05
  • @nix9247 Did you already have time to review my answer? If it helped, please mark it as accepted so others can see this has been solved. If not, please leave a comment so the community can have a look at it and try to help you out. Sep 17, 2019 at 12:58

1 Answer 1

0

From what you posted it looks like you have the <form action="%%=CloudPagesURL(1345)=%%" method="post"> code on your confirmation page?

If that is the case your confirmation page would never be invoked as the confirmation page should be the action of your preference center page's form.

So you need to wrap a form-tag (like the one mentioned above, with the ID of your confirmation page) around your input-tags in your preference center:

<form action="%%=CloudPagesURL(1345)=%%" method="post">
    %%[IF @optin==1 THEN ]%%
        <label>
            <input id="Optin" name="Optin" type="checkbox" checked="true" value="Optin" onclick="CheckUnSubscribe()"> I wish to receive communications by email from Company.
        </label>
    %%[ELSE]%%
        <label>
            <input id="Optin" name="Optin" type="checkbox" value="Optin" onclick="CheckUnSubscribe()"> I wish to receive communications by email from Company
        </label>
    %%[ENDIF]%%
</div>
<div class="btn-wrapper">
    <button class="btn btn-default button" type="submit">Save your Preferences</button>
</div>
<input type="hidden" name="ExternalID" value="%%=v(@externalID)=%%">
</form>

You must log in to answer this question.

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