0

I am trying to create a simple form with one or two fields in the email templates.I have created the same before in landing pages and I am not sure we can achieve the same in email templates .And my code sample is below which throws validation error. Since the code is in email I don't where should I post any help regarding this will be helpful.

%%[
    var @test
    set @test="test survey"
    set @UrlThispg = RequestParameter('PAGEURL')
]%%
<html>
  <head>
  </head>
  <body>
  <p>
           hi welcome:%%=v(@test)=%%,URL is : %%=v(@UrlThispg )=%% 
  </p>
 <form id="formName" action="%%view_email_url%%" method="post" enctype="application/x-www-form-urlencoded">

<input type="text" name="id">
<input type="submit" value="submit">
<script runat="server" type="text/javascript" >
Platform.Load("core", "1");
if (Request.Method == "POST") 
{

}
</script>
</form>
</body>
</html>

Error I get during Generate Preview is

**An error occurred when attempting to execute a Javascript block. See inner exception for detail. Script: Platform.Load("core", "1"); if (Request.Method == "POST") { }

ListID: 22920 Index: 16

Value cannot be null. Parameter name: value Line: 3 Char: 16 if (Request.Method == "POST")

{ **

1

The VAWP URL is a personalization string, not an AMPScript variable, so it needs to be referenced differently.

%%[
    var @test
    set @test="test survey"
    set @UrlThispg = RequestParameter('PAGEURL')
    set @VAWP = AttributeValue("view_email_url")
]%%
<!-- snip -->
<form id="formName" action="%%=v(@VAWP)=%%" method="post" enctype="application/x-www-form-urlencoded">

or

%%[
    var @test
    set @test="test survey"
    set @UrlThispg = RequestParameter('PAGEURL')
]%%
<!-- snip -->
<form id="formName" action="%%view_email_url%%" method="post" enctype="application/x-www-form-urlencoded">

That being said, I'd suggest you look into utilizing the _messagecontext personalization string for determining if the email is being rendered via VAWP or not.

NOTE: Also keep in mind that the view_email_url is transient -- meaning if you are depending on data in your sending Data Extension, if that data is gone, there's a possibility that your VAWP destination will be broken.

  • Hi Adam thanks for your comments. I am using this snippets in Email templates but I am not sure about the value in the "Action" as i don't have access to landing pages I have just given some tries.Also I have used messagecontext but that doesnt give me any ideas.Any insight on what will be the value for action?When i try generate preview i get error – Manoj Chandran Jul 7 '16 at 14:15
  • I have just updated the question with the error – Manoj Chandran Jul 7 '16 at 14:20
  • Request.Method is only available on landing pages, which is why I suggested you use _messageContext. You need to detect when the code is rendered in an email vs the VAWP. – Adam Spriggs Jul 7 '16 at 14:50
  • Hi Adam I was able to post to VAWP based on the messagecontext but is there a way to access the form field on post as request methods will not be supported in Emails is there any other methods? – Manoj Chandran Jul 8 '16 at 11:05
  • Hi Adam I was able to fix the errors in – Manoj Chandran Jul 8 '16 at 14:48

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.