I'm trying to output message if there is an error and i have very little knowledge in javascript in general.
Could I get some feedback on if the following would work or how I would go about :
- If empty parameters, output "Sorry, there was an error"
- If there is an error, output "Sorry, there was an error"
Thank you in advance!
<script runat="server">
Platform.Load("core","1.1.5");
try {
</script>
%%[
/* Retrieve Parameters */
SET @subscriberkey = _subscriberkey
SET @jobid = jobID
SET @firstname = RequestParameter("FirstName")
SET @email = RequrestParameter("Email")
/* Handle Empty Parameters */
IF EMPTY(@subscriberkey) OR EMPTY(@jobid) OR EMPTY(@firstname) OR EMPTY(@email) OR @subscriberkey =='' OR @jobid == '' OR @listid == '' OR @Email == ''THEN
SET @message = "Sorry, there was an error."
ENDIF
/*Lookup DE and Update if doesn't exist */
SET @Rows = LookupRows('DEName', "SubscriberKey", @subscriberkey)
IF RowCount(Rows) > 0 THEN
SET @message = "You've already registered."
ELSE
SET InsertDE = InsertData('DEName','SubscriberKey', @subscriberkey, 'Email',@Email)
SET @message = "Thanks for registering"
ENDIF
]%%
%%=v(@message)=%%
<script runat="server">
} catch (e) {
Write("<br>" + Stringify(e))
}
</script>