Activity Forums Salesforce® Discussions How to resolve the error in If-Else in Salesforce Marketing Cloud AMPscript?

  • How to resolve the error in If-Else in Salesforce Marketing Cloud AMPscript?

    Posted by Udit on April 9, 2020 at 12:15 pm

    I am trying the If-Else condition in the code but getting the error "Internal server error". Could you please help me out on the code given below:
    %%[
    IF RequestParameter("submitted")==true THEN
    Var @insert

    SET @firstname = RequestParameter("First Name")
    SET @lastname = RequestParameter("Last Name")
    SET @phone = RequestParameter("Phone")
    SET @email = RequestParameter("Email")
    SET @rating = RequestParameter("Rating")
    SET @description = RequestParameter("Description")
    SET @status = RequestParameter("Status")

    %%[IF Rating>=0 AND Rating<=5 THEN]
    SET @insert = InsertData("UC_Target_DE",
    "First Name",@firstname,
    "Last Name",@lastname,
    "Phone",@phone,
    "Email", @email,
    "Rating",@rating,
    "Description",@description,
    "Status",@status)

    %%[ELSEIF Rating>5 AND Rating<=10 THEN}%%
    SET @insert = InsertData("MT_Target_DE",
    "First Name",@firstname,
    "Last Name",@lastname,
    "Phone",@phone,
    "Email", @email,
    "Rating",@rating,
    "Description",@description,
    "Status",@status)

    %%[ENDIF]%%
    ]%%
    %%[ ELSE ]%%
    <table style="padding: 20px;"><tr><td>
    <h2>Please Fill the form:</h2>
    <form action="%%=RequestParameter('PAGEURL')=%%" method="post">
    <label>First Name: </label><input type="text" name="firstname" required="false">
    <label>Last Name: </label><input type="text" name="lastname" required="false">
    <label>Email: </label><input type="email" name="email" required="true">
    <label>Phone: </label><input type="phone" name="phone" required="false">
    <label>Description: </label><input type="text" name="description" required="false">
    <label>Status: </label><input type="text" name="status" required="false">
    <label>Rating: </label><input type="number" name="rating" required="false">
    <input name="submitted" type="hidden" value="true">
    <input type="submit" value="Submit">
    </form>
    </td></tr></table>
    Data saved = %%=v(@insert)=%%
    %%[ ENDIF ]%%

    Udit replied 4 years, 8 months ago 1 Member · 0 Replies
  • 0 Replies

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Popular Salesforce Infographics