Hello all I have the below code where it upserts into a DE. I also want to redirect to a new cloud page on clicking submit. The issue is I did find a way to do it by using action="%%=RedirectTo(CloudPagesURL(@optoutRedirect,'id', @id))=%%"

But then it does not upsert into a DE so I lose that functionality. Anyway to make it INSERT into a DE AND also redirect to a new website or cloudpage?

<script runat="server">
Platform.Load("core", "1.1.1");

if (Request.Method == "POST") {
  /*var subscriberKey = Request.FormParameter(_susbcriberKey);*/
  var subscriberKey = Request.GetQueryStringParameter("sfmc_key");
  /*var reason = Request.FormParameter("reason");*/
 var reason = Request.GetFormField("reason");
  var deName = "Unsubformsubmit_xxxx"; /* Replace with the name of your data extension */
  var deRows = Platform.Function.InsertDE(deName, ["SubscriberKey", "reason"], [subscriberKey, reason]);
  if (deRows > 0) {
    // Success
    Platform.Response.Write("Form submitted successfully.");
  } else {
    // Error
    Platform.Response.Write("Error submitting form.");

  <form method="post"> 
            <select name="reason" id="selectBox" onchange="testfunc();">
            <option >1</option>
            <option >2</option>
            <option >3</option>
            <option >4</option>
            <option >5</option>
          </select> <br>
            <textarea  style="display:none;" class="text-field" id="textField" name="reason"></textarea> <br>
          <button onclick="document.forms[0].submit()" type="submit" class="button">Submit</button> 
  • why don't you just give the URL like <form action=<yourURL> Feb 28 at 5:05
  • Did you figure out a way to do this? I'm attempting to build the same functionality Apr 27 at 11:27

1 Answer 1


InsertDE is for emails. InsertDATA is what you want on cloudpages.

See here (green boxes): https://ampscript.guide/insertdata/

vs here: https://ampscript.guide/insertde/

In general, this should work. An insert / upsert on a cloudpage does not prevent the redirect. Definitely try exchanging that function first.

You must log in to answer this question.

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