-
How to resolve the error in If-Else in Salesforce Marketing Cloud AMPscript?
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 @insertSET @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 ]%%
Log In to reply.
Popular Salesforce Blogs
![](https://images.forcetalks.com/wp-content/uploads/2023/02/12145956/sa_1676213931Salesforce%20Deployment%20using%20gearset-1024x536.png)
Salesforce Deployment Using Gearset: All You Need to Know
What is Gearset? Gearset is the complete DevOps solution. More quickly and easily than ever before, we assist teams in comparing, moving, and tracking changes between…
![](https://images.forcetalks.com/wp-content/uploads/2022/02/24115000/sa_1645703274banner2-1024x535.png)
Most Essentials Tools for Building Salesforce Lightning Components
Any Salesforce developer who wants to be at the top of his game should know how to work well with Lightning Components. With Lightning Components,…
![increase sales](https://images.forcetalks.com/wp-content/uploads/2021/02/19110628/increase-sales-1024x576.jpg)
How to Increase Your Sales Leveraging Digital Transformation? | Salesforce Guide
Now, the shopping experience is not confined to stores. It has been spread across multiple channels including online, mobile, and over the phone. With shoppers…
Popular Salesforce Videos
Integrate Salesforce with External System using REST API
In this video, Path to Code explains the following topics: - What is API? - Introduction to REST API - Using cURL to consume Rest…
Marketing Cloud To Become Customer Company
Leverage Marketing Cloud's ability to engage customers by delivering premium personalized experiences and building meaningful relationships with them. Contact Cyntexa to boost your business with…
How To Change Opportunity Stages In Salesforce
If you're finding that you need to change the stages of opportunity in Salesforce, don't worry, it's easy to do. In this video, Gary Smith…
Popular Salesforce Infographics
![](https://images.forcetalks.com/wp-content/uploads/2022/12/20092653/sa_1671528364salesforce%20trends%20for%202023%20forcetalks.jpg)
Top Salesforce Trends For 2023
When it comes to managing customer databases, Salesforce is leading the pack. Companies are increasingly relying on this powerful tool for its unrivalled flexibility and…
![](https://images.forcetalks.com/wp-content/uploads/2019/09/13140633/sa_1568383382screenshotinsightaas.com2019.09.1319_32_22.png)
Infographic: State of Service 2019
Did you know that 64% of people think that customer experience is more important than price in their choice of brand? The new trends in customer service…
![](https://images.forcetalks.com/wp-content/uploads/2019/01/28141202/sa_1548684589DRIP_Summer18Featuresinfog_title.png)
New Pardot Features: What was delivered in Summer ’18
New Pardot features, summer '18. Pardot has treated us to many enhancements across the core tool and related products. This infographic gives you an overview…