I won't lie, I have wasted two days on this. I should have given up hours ago but seemed so close that I have continued to persevere beyond what was sensible.
Client side script that has worked for 4-5 years. Purpose is to fill in a pdf form based on web submitted data, append some pages created from filemaker layout and re-save to container. (Note: The entire pdf document cannot be created from filemaker layouts)
- Creates a folder on local PC using Base Elements plugin.
- Exports an adobe document with form fields from a container field into the local folder.
- Creates a chunk of XML in a text field and then uses Base Elements to create this as a file with a .fdf extension into same folder.
- Creates another file in the same folder with VBA code that will open .fdf file and then do a save as .pdf (again using BE plugin)
- Opens the VBA file so the code runs (again using BE plugin).
- Appends two further pages to the existing three page pdf in the folder based on a filemaker layout (using pdf append feature in FM).
- Inserts the completed pdf back into a container field.
(If you have played with adobe .fdf files then some of this will make sense - as long as you have the form pdf and the .fdf file in the same folder then opening the .fdf will open a pdf with the form fields filled with data.)
The problem is that Adobes Enhanced Security means you have to "allow" the document to do this and Adobe keeps a list of trusted documents. The script does not handle this well when it is run under a new profile and so the form will fail to compile with data. After a long period of remotely adding the trusts needed to users machines I decide the best idea would be to PSOS this script. Then I could create the trust on the server and know that it was going to run as expected.
The PSOS script runs to completion as expected, I had to change some things in the original script but I was able to do this without too much trouble. The issue though is the the resulting file does not have the fdf data in it. So it is running the VBA fine in that I am ending up with a 5 page pdf as expected back in the container. Unfortunately the first 3 pages have the form fields but not the form data.
What I know:
- If I run the VBA file created by the PSOS script on the server it does create a populated pdf!
- I have added in error capturing to the VBA to email me if there is an error and it does not capture one when run via the PSOS script.
- I have tried running the VBA via PSOS using the plugin both via an open file and run as a ExecuteSystemCommand. In theory if it works when I log into the FMS server and run the file then it should work when the PSOS script runs it. The plugin is running the VBA as it is creating a pdf document as expected - so it is not an issue of the VBA not running.
- Thinking it might be permissions I have tried creating and doing this from a variety of locations, filemakers data documents folder and temp folder which I know PSOS likes and then in a folder I created and gave broad permissions to. No dice.
The crux is the matter is that this is almost impossible to troubleshoot. You can't debug it. If the file was not being created with the expected 5 pages then I would assume that the VBA had an issue but it only appears to not work in entirety when using PSOS. The VBA created by the PSOS works as expected when I log into the fms server and run it + I know that to a point the PSOS is running the VBA as it is creating the expected file with the filename being passed into the VBA.
I can go back to adding trusts to users adobe clients but as you can see I just feel like I am so close... yet so far away!
I know the fact that I am integrating Adobe and VBA with FM makes this not an ideal question to post but in a last desperate bid I wondered if anyone had any idea's on what else could be at play. (Windows Server 2012)
Many thanks if you made it this far through my post!