0

I am trying to create a survey landing page in cloudpages that will pull data into an existing data extension with AMPscript, but I am getting a 500 server error when the AMPscript is in. I am working with the salesforce team and they said that the error is in the insertData line, but I am unable to identify it. Can you see anything in this code that might be causing the error? I am very new to salesforce and coding, so sorry if it is obvious but could not find any fixes online that helped. Thank you!

%%[
set @firstname = RequestParameter("First Name")
set @lastname = RequestParameter("Last Name")
set @email = RequestParameter("Email")
set @phonenumber = RequestParameter("Phone Number")
set @zipcode = RequestParameter("Zip Code")
set @age = RequestParameter("Age")
insertData("DATA EXTENSION","First Name",@firstname,"Last Name", @lastname, "Email", @email, "Phone Number", @phonenumber, "Zip Code", @zipcode, "Age", @age",)
]%%
1

Your function AMPscript function - InsertData has 3 issues:

  1. You did not set a variable for it;
  2. At the very end you have double-quotes after the @age variable;
  3. Also at the very end, after the @age variable you have a comma but there are no more additional attributes and values specified.

Thus, your function should look like this -

SET @insertData = InsertData("DATA EXTENSION", "First Name", @firstname, "Last Name", 
 @lastname, "Email", @email, "Phone Number", @phonenumber, "Zip Code", @zipcode, "Age", @age)

You can review how to properly set up the function here.

6
  • Thank you Niko ! Unfortunately, that still gives me a 500 error when I try to publish the page.
    – trh31625
    Jul 9 at 19:45
  • I assume Data Extension's name is correct, then maybe when you are trying to insert the data into the DE, you are exceeding the field's length and/or generally cannot pass the validation for specific Data Type fields for example, "Email Address". The syntax of your RequestParameter and my InsertData functions are correct at this point.
    – Niko
    Jul 9 at 19:56
  • Thanks! I don't think field length is the issue. Do you know how I can troubleshoot validation for data type fields?
    – trh31625
    Jul 9 at 20:06
  • Review this article to troubleshoot the error you have. Btw, also consider Primary Key violations and fields that are non-nullable and that are skipped in your InsertData Function.
    – Niko
    Jul 9 at 20:29
  • Thank you, this is the message I received in return: InsertData Function is not valid in content. This function is only allowed in a non batch context.\r\n Function: InsertData(\"DATA EXTENSION\", \"FirstName\", @FirstName, \"LastName\", \r\n @LastName, \"Email\", @Email, \"PhoneNumber\", @PhoneNumber, \"ZipCode\", @ZipCode)\r\n Error Code: OMM_FUNC_CONTEXT_ERR\r\n - from OMMCommon\r\n\r\n\r\n\r\n"}
    – trh31625
    Jul 9 at 20:50
0

Assuming you are using the new Web Studio that's based on content builder, then you don't want to use InsertData, instead you need to use InsertDE, then should fix the 500 error it is experiencing right now.

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.