I am working on a preference center and looking to use the Upsertdata to populate/ or update records in a data extension. The code is rendering fine in cloud pages but is not actually pulling in. records on submit. Is there something I'm missing in the code? Thanks for your help! The data extension fields are (First Name, Last Name, EmailAddress, PMOSH, OMSA, PMML, OMSACyber, PMASE)

<script runat="server" type="text/javascript">
try {

var @Contact, @ContactRow, @FirstName, @LastName, @EmailAddress, @PMOSH, @PMASE, @PMML, @OMSA, @OMSACyber, @Status, @message, @subKey, @ErrorMessage, @isSubmitted

Set @Message = Concat(@Message, "email: ", @EmailAddress)

IF RequestParameter("isPosted") == "true" THEN   

   /* update Preferences DE and All Subscribers table */

    set @PMOSH = RequestParameter("PMOSH")
    set @PMASE = RequestParameter("PMASE")
    set @PMML = RequestParameter("PMML")
    set @OMSA = RequestParameter("OMSA")
    set @OMSACyber = RequestParameter("OMSACyber")
    set @subKey = RequestParameter('sKey')
    set @isSubmitted = RequestParameter("IsSubmitted")
    set @Unsubscribe = RequestParameter("Unsubscribe")

    UpsertData("Master_List_DE",1,"EmailAddress",@EmailAddress, "PMOSH", @PMOSH, "PMASE", @PMASE, "PMML", @PMML, "OMSA", @OMSA, "OMSACyber", @OMSACyber)    

    Set @Message = Concat(@Message, "Updated preferences for", @Email_Address, "!")
    Set @SuccessMessage = "Updated preferences!"


/* update SFMC All Subscribers Status field. Subscriber will be added if they are not already there */

set @sub = CreateObject("Subscriber")
SetObjectProperty(@sub,"SubscriberKey", @subscriberKey)
SetObjectProperty(@sub,"Status", "Unsubscribed")

Set @options = CreateObject("UpdateOptions")
Set @save = CreateObject("SaveOption")
AddObjectArrayItem(@options,"SaveOptions", @save)

Set @statusCode = InvokeUpdate(@sub, @statusMsg, @update_sub_errorcode, @options)

if @statusCode != "OK" then
    set @error = "All subscribers not updated."

<script type="text/javascript" runat="server">
catch (e) {
  Write("<br>e: " + e);

<form id="TestPref" action="?" method="POST" enctype="application/x-www-form-urlencoded">
    <div style="display: flex;">
      <div id="Level2LeftRightSide" style="width: 100%; display: inline-block;">
        <div id="TransCommFreqHeading" style="background-color: lightgray">
          <h4 style="color: black; padding-top: 5px; padding-bottom: 7px; position: center; text-align: center">
            <input type="checkbox" name="PMOSH" value="%%=v(@PMOSH)=%%"="" %%=Iif(@PMOSH=="true", "checked", "")=%% onchange="this.value=this.checked">PMOSH<br>
            <input type="checkbox" name="PMASE" value="%%=v(@PMASE)=%%"="" %%=Iif(@PMASE=="true", "checked", "")=%% onchange="this.value=this.checked">PMASE<br>
            <input type="checkbox" name="PMML" value="%%=v(@PMML)=%%"="" %%=Iif(@PMML=="true", "checked", "")=%% onchange="this.value=this.checked">PMML<br>
            <input type="checkbox" name="OMSA" value="%%=v(@OMSA)=%%"="" %%=Iif(@OMSA=="true", "checked", "")=%% onchange="this.value=this.checked">OMSA<br>
            <input type="checkbox" name="OMSACyber" value="%%=v(@OMSACyber)=%%"="" %%=Iif(@OMSACyber=="true", "checked", "")=%% onchange="this.value=this.checked">OMSACyber<br>
            <div style="text-align: center;">
                <input type="submit" class="buttonstyles" style=" font-size: 16px; font-family: Arial; color: #FFFFFF; text-align: center; text-decoration: none; background-color: #5D5D5D; border: 1px solid #5D5D5D; padding: 10px; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px;">
  • You've got some curly quotes in your form and also some malformed HTML, e.g.: name="PMOSH” value=" %%=v(@PMOSH)=%%"="" – Adam Spriggs Aug 22 '19 at 12:02
  • And please take the time to format and indent your code block before posting. It'll help us help you. – Adam Spriggs Aug 22 '19 at 12:03
  • @AdamSpriggs Thank you for pointing that out. Also noted about the format and I will make sure to do that before posting. I did update the code but I'm still not getting any results... is this correct URL format in terms of how to test the page (pub.s6.exacttarget.com/…) – MB360 Aug 22 '19 at 12:37
  • Please update your question with your latest code. We don't really have enough info to investigate. – Adam Spriggs Aug 22 '19 at 13:26
  • Done. Thanks for the help so far! – MB360 Aug 22 '19 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.