Via script, I'm trying to close the current form and reopen it, so I can quickly clear all data values (this is a multi-view form). Also, this is a fully-trusted form.
On my development laptop the script works like a champ - on all other machines it fails on the NewFromSolution line with a "permission denied" script error.
(I've isolated this problem down to some simple code). Here it is:
1. Create a TestForm.xsn with one Button - btnCloseAndReopen. Add the script below on the button's OnClick event.
function btnCloseAndReopen::OnClick(eventObj)
{
var oActiveDoc = Application.ActiveWindow.XDocument;
var ActiveURI = oActiveDoc.URI;
var sURI = XDocument.Solution.URI;
XDocument.UI.Alert("About to close Active Document...");
Application.XDocuments.Close(oActiveDoc);
// or XDocument.View.Window.Close(true);
// or Application.XDocuments.Close(0);
Application.XDocuments.NewFromSolution(sURI);
}
2. Use regform to fully trust the form (/T Yes).
3. Run it by double-clicking TestForm.xsn
---
On my Development machine, it works like a champ. On everyone else's machine in the world, it fails on the NewFromSolution line, producing the message box: "A runtime error has occurred. Do you wish to debug? The following error occurred: permission denied ...
I can understand why it may not work (perhaps it's lost context, but why does it work on my machine). By the way, for each test, I recreated the .XSN from scratch on each individual machine.
If I remove the "Application Close" line, the form works on all machines, but obviously keeps creating more and more XDocuments. I don't want this.
What am I doing right (on my machine), and wrong (on others). Is this a timing problem? MDI. Or Dumb user error. I've used regmon, filemon, compared internet advanced settings to no avail.
Any ideas?
Thanks,