I am using the below SSJS to remove a row from a data extension.

<script runat="server" > 


            var DeleteCustomerNumber = Variable.GetValue("@DeleteCustomerNumber");
            var DeletedResult = Platform.Function.DeleteData('ReferenceMicrositeModifyData',['CustomerNumber'],['1111']);
          catch (e) 

            Write("<br><br>Error: " + Stringify(e));



This works successfully, and removes the record with CustomerNumber '1111' from the data extension, but the below error page is shown in the landing page.

enter image description here

If I change the static value to one that does not exist in the data extension, then I do not get the same error page.

I have the exact same issue if I try and delete the row with ampscript.

Any ides what might be going on here?

  • 1
    When doing a "Save and Publish" the preview will execute the code. So your record may be deleted before you even visit the page URL. Having said that, I have no explanation as to the 500 error. Are you sure there is no other code on the page than what you have shown? Aug 19, 2019 at 6:18
  • There is other code on the page, so I will add some more to my original post. The script is nested in an IF condition, so the send preview will not trigger it. It will just trigger when a specific link is clicked. Aug 19, 2019 at 6:21
  • Ok based on Josh's prompt, I ran some additional tests and it looks like there is something in my page that is causing this script to not work. If I put this script in the head tag it still errors out the page. If I then delete the entire body content though, the script then works. I don't know how the body content could affect the script when the script is in the head tags, but I will run some more tests before dropping a code bomb on here. Thanks for your help so far. Aug 19, 2019 at 6:48

1 Answer 1


Issue was that I had a table that displays all records in my data extension, and due to the order that SSJS and Ampscript executes, my ampscript for loop was counting all records in the DE, even though one of the records had been deleted!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .