We are adding below code to check if Data extension is present or someone has deleted accidently , as we are fetching content ( with only one row) from DE to display on a cloudpage if someone delete it accidently there should not be 500 error , so we implemented try and catch in SSJS.
But also we need to make sure if someone clears Data from DE accidnetly then also that should capture in Try block , we tried but without any success below is the code
<script runat=server language="JavaScript">
var HeaderDE , HeaderDECheckRowCount ;
HeaderDE = "DataExtension_Name";
try {
HeaderDE = Platform.Function.LookupRows(HeaderDE,'Id','1'); /* to check DE is exist or not */ - working fine
HeaderDECheckRowCount = Platform.Function.rowcount(HeaderDE); /* to check DE has at least one row */ - not working
if (HeaderD > 0)
{
HeaderDEExist = true;
}
else
{
HeaderDEExist = false;
}
}
catch (e)
{
HeaderDEExist = false;
}
Platform.Variable.SetValue("@HeaderDEExist",HeaderDEExist);
</script>
We are able to check and handle if we delete DE but not able to catch if someone clear data from DE , DE has only one row