Thanks Enrico, apologies for the delayed response. I have implemented the changes you suggested and I am still getting the HyperEvent JS exception, but now it just says - SyntaxError: Invalid or unexpected token.

The weird part is, the objectscript code is executing and downloading the file from the SFTP as expected, just catching the HyperEvent exception as well, which seems odd to me.

Thanks for all you help so far, and hopefully you may be able to help further.

I do, in this case, the code is - 

            Set sc = sftp.Get(remoteFile, localFile, "0666")
                        Set sc = sftp.Get(remoteFile, localFile, "0666")
            If $$$ISERR(sc) {
                Write "Error downloading file: ", fileName, !
            else {
          Write "File Successfully Downloaded", fileName, !
            }

However, if I remove the Write commands, this error goes through every Write command and I am not sure how else to log this for debugging issues.

Hi Enrico,

Thanks for your reply.

So currently this is all in a single CSP page (HTML, then JS, then ObjectScript). I have a button that when clicked, calls the JS function onClick=handleFormSubmit().

Then within the JS handleFormSubmit() function, this is where  #server(..DownloadFiles(document.getElementById('fileList').value))#;                                                                        is called, which invokes the method download files, which is in <script> tags in the same CSP page. The tag looks like - 

<script language = "Cache" method = "DownloadFiles" RunAt="Server" ARGUMENTS = "fileList:%String">

Hopefully this is helpful, but if you need more info, let me know.