I am writing a little app where I press a button on a Zen form. It calls a ZenMethod that uses zenPage.launchPopupWindow() to provide me a way to choose a file. I then click on an upload button that calls a csp cache language script file that runs on the server, that grabs the contents of the file and stuffs it into a global. I want it then close and return to the parent window to continue processing the contents of the file. I have tried placing the javascript code that closes the window and calls a function in the parent window in different places, but it is not closing the window or calling back to the parent window. I have pasted the contents of the CSP page. I am hoping someone can help me with what I am doing wrong.
This is based on upload.csp in the SAMPLES namespace
<!-- Copyright (c) 2001 InterSystems Inc. ALL RIGHTS RESERVED. -->
<csp:class description="Upload Client Consultations file.">
<html>
<head>
<script language = "JavaScript" >
function exitPopup() {
opener.processImport();
window.close();
}
</script>
</head>
<body bgcolor="#CCCCFF">
<!-- HTML Form to submit the file. You must specify the enctype="multipart/form-data" -->
<!-- for this to work -->
<form enctype="multipart/form-data" method="post" action="upload.csp">
Choose Client Consultation file: <input type=file size=30 name=FileStream>
<p>
<ul><input type="submit" value="Upload file"></ul>
<p>
</form>
<!-- As form is submitted to this page look to see if we have the stream in the %request object -->
<csp:if condition='($data(%request.MimeData("FileStream",1)))'>
<ul>
<script language="Cache" runat="server">
New bytes
Set bytes=%request.MimeData("FileStream",1).Read()
Set bytes=##class(%CSP.Utils).DecodeData(bytes)
If $Data(^CacheTemp("UploadedCSV")) Kill ^CacheTemp("UploadedCSV")
Set ^CacheTemp("UploadedCSV")=bytes
&js<exitPopup();>
</script>
</ul>
</csp:if>
</body>
</html>
Thank you for your time