Got it working! Can now update backend files from within the primary database.
First, here is the crux of the problem, as Seed Code explained it to me (paraphrasing your words here Jeff):
You're using the separation model in your mobile solution, and you're running the "Check for Updates" script in the backend data file, but initiating it from the main UI file. The reason you're getting the "file is locked" error message when you try to install an updated version of your backend file is that the UI file is forcing that file to stay open. Try it on your desktop. You can't close the backend file. I guess you could say GoZync wasn't designed to support the separation model in the mobile solution.
To do what you want to do, you'd have to explicitly close the UI file at some point in the update process, so that when GoZync closes the data file it's trying to replace, that file stays closed. Maybe a subscript toward the beginning of the "Check for Updates" script in each data file that closes the UI file before it proceeds?
So it took a number of steps to work around this--don't know if it is the most concise method or not--but it works (and was the only method I found to work out of almost 10 methods I tried).
- First, when the main file needs to update the backend file, have it directly call the Zync - Check For Updates script from that backend file.
- Within each backend file, add a global number field; for example, I created an updateFlag field in my References table.
- Within each backend file, edit the Zync - Prep And Upload New File script, and in the section where it states # RUN PREP SCRIPT HERE add the steps
- Set Field [References::updateFlag; 1]
- Commit Records/Requests
- Optionally, add some steps to you Main Database's On Open script that you want to run after the backend file is updated and your main file is reopened. I am taking the user back to their original layout, and providing a confirmation message:
- If [Get ( ScriptParameter ) = "backendUpdate"]
- Go to Layout [layout that initiated the update, which is different that the default home screen]
- Show Custom Dialog ["Update Successful"; "more text"]
- End If
- Within each backend file, edit the script that runs when the file is first opened (and if you don't have one, create a script and assign it as a script trigger in the backend database's File->File Options->Script Triggers section.) Add these steps:
- If [References::updateFlag = 1] //runs only after a new version is downloaded
- Set Field [References::updateFlag; 0]
- Commit Records/Requests
- Open File ["Main Database"] //main database file was closed during the update process, need to open it back up ...
- Perform Script ["Load Database" from file:"Main Database"; Parameter: "backendUpdate"] //... and optionally execute another script
- Close File [Current File] //close the backend file, leaving us back in the main file
- End If
- Edit GoZyncMobile's Check For Updates (File) script. About 25 lines up from the bottom of this script, before the line #Queue the zerver to inztall the new filez, add one line of code. This line, when placed here, is called if there is an update to your backend file, and closes your main file before GoZync's big Install Files script is called so that it isn't locking your backend file.
- Close Window [Name: "Window Title of main database:] //maybe Close File would work better by being more robust?