Skip to content

Instantly share code, notes, and snippets.

@zuzannamj
Last active January 29, 2021 17:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zuzannamj/08fe8d5b4f99d32b21ff3347515c1923 to your computer and use it in GitHub Desktop.
Save zuzannamj/08fe8d5b4f99d32b21ff3347515c1923 to your computer and use it in GitHub Desktop.
<script runat="server">
Platform.Load("Core","1.1.1");
try{
</script>
%%[
set @email = emailaddr
if (@email != "") then
set @rows = LookupRows("LeadDataExtension","Email", @email)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
set @row = Row(@rows, 1)
set @FirstName = Field(@row,"FirstName")
endif
endif
]%%
<script runat="server">
}catch (e) {
Write("<b>Error Message:</b> " + Stringify(e.message) + "<br><br><b>Description:</b> " + Stringify(e.description));
}
</script>
Hello %%=v(@FirstName)=%%!
@tibu
Copy link

tibu commented Jan 29, 2021

One note: if you want to store the error message in an error log DE, you can add this after Write:

var targetDE = 'xxxxxxx-xxxxxxx-xxxxxxxxx'; //pass external key of the target DE
var logDE = DataExtension.Init(targetDE);
var errorMsg = Stringify(e.message)
logDE.Rows.Add({ Error: errorMsg });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment