We have registration and Thank you cloud page. I'm currently inserting records from Thank you(processing) cloud page to DE using AMPSCRIPT. Mobile Number/Email address is primary key, I need to display error message in registration page if record is already exist. I'm new to SFMC, kindly help me on this issue.
1 Answer
You have to use different Ampscript functions to accomplish this.
First use lookupRows to check if the emailaddress/subscriberkey exists in your data extension. RowCount gives the count of matching rows. If rowcount is more than 1, then use RaiseError to display an error message
%%[
var @result = RowCount(LookupRows('PostalCode','City','Indianapolis'))
if @result = '0' then {
/*do you action*/
ouput(concat("All good"))
}
else{
raiseError("Error raised")
}
endif
]%%
-
Thanks for your input. Can I validate this without redirecting to "thank you page"? Currently all my AMPSCRIPT is in "thank you page". If record is already exists, it should display error message in Registration page itself without redirecting to "thank you page".– BharathAug 21, 2018 at 7:47
-
-
1To expand, you can use the conditional to decide your content. E.g. if result = 0 then display thank you html, else display you have already submitted html. I do not recommend raiseError in a LP, it is poor customer experience to display the SFMC error page to them. Aug 21, 2018 at 12:39