That error is generally seen when the path is incorrect. I'd hunt around in the code where you're creating the path.
path works when unhosted, how do I need to change the path for hosting?
turn off server, open file with FM Pro .. test ... works
open file with server .. open 'remote' with Pro .. test .. fails.
You'll have to provide the actual calculation you use to generate the path. It should be using the "Get ( DocumentsPath )" function. THat returns an entirely different location for FMS that your User account. If you hard coded any part of the path that is not in the FMS Documents folder then it can't work.
I did provide it:
where "$invoice" is the number of the invoice. and "file:Invoices/" is a subfolder in the directory of the hosted file (ie: in the library subfolders where server lives).
full path for that would be:
I have successfully made it save into the LOCAL fm Pro directory (ie on the user's machine), or a subdirectory of that but I can't seem to figure out what path might work to move that to a server folder where everyone can see the same folder.
I'll look at that Get function.
Get(DocumentsPath) & "/Databases/Integrator/Invoices/"&Orders::InvMemNo&".pdf"
Does NOT work. but would seem to be what I want give it, based on the description in the HELP for the Get function:
When running on FileMaker Server, Get(DocumentsPath) returns the location of the Documents folder, which is in the same folder as the server's Backups, Databases, and Scripts folders. The Documents folder is used as a shared location that scripts from different sessions or other processes on the machine can use to import or export files."
I put that in a variable named $Invoice and used the variable as the path in the export command.
FYI the Get function is returning the user's documents folder, not the FMS document folder as indicated by help; that's got to be the issue.
I created a custom dialog to display it.
When the script is run on the FMS it returns the FMS Document folder. When you run it as the User then it returns the user account's document folder. Its all a matter of what user account the script is running under. When FMS is running it then it is using the fmsadmin account.
Since calculation operations are not allowed in the Path field, it doesn't do calculation engine operations, it can't work.
You need to do it as a real calculation in the Set Variable script step.
Set Variable [ $path ; "file:/" & Get ( DocumentPath ) & $myFileName & ".pdf" ]
Then you use ONLY the variable "$path" when setting the value for file location.
I can make this work the way I want IF I can point the save (and retrieve, I want to put this in an email after) to the Server's folder.
I think the step or funtionality I'm missing is:
how do I "run this under the server" and not the user.
If put in your suggested code, and access the remotely hosted script, it points to my local documents folder.
in other words: I run the server-hosted script on my local machine "save as pdf to $path" in your example, the file arrives on my local machine.
Your instructions (and thank you so much) would seem to indicate that if I run this as a client to the hosted machine, the Get(DocumentPath) should make the file save on the host computer, but that does not happen.
Somehow I have to make the *server* run the script and not the client? How?
/me runs to find a box of Roger's Victoria Creme chocolates as a reward
You can't run the script as a server script. Save as PDF is not a server-compatible script step.
Thanks for bringing a little sanity to my zeal. I totally missed that in the original post.
All script steps used in the script must be server compatible. Be sure to change the "Show Compatibility" in the lower left corner of the scripts dialog to "Server" so it grays out unusable script steps.
However, to explain "running a script on FMS".
In order to run the script on FMS you must set up a scheduled event. This tells the FMS which script to run, what FMP account to use, and when to run it. When running as a scheduled event it runs on FMS using the fmsadmin account. That restricts the locations to the ones FMS has access to. For security reasons FMS does not have access to remote volumes.
Bruce's answer is technically the correct one. I created a work-around with Choc's advice.
I'll summarize the situation for others that may be looking at this in future:
I can't save the file on the server's network volume as I had wished, due to the fact that FMS does not have access to server volumes for security reasons.
When I turned on compatibility view, save as PDF greyed out for server, but it does, actually work for me.
I made a folder in the user's local-machine documents folder named "Invoices"
I made a variable for the file's name: $Invoice with the calculation: Orders::InvMemNo&"-"&Customer::ShortName&".pdf"
I made a global varialbe for the path to the user's local drive: $$InvoicePath with the calculation: Get ( DocumentsPath )&"Invoices/"&$Invoice
This saved the file with the invoice number and name of client on the user's local home folder in the subfolder "Invoices"
I used a global Variable so that I could use it in an optional email script. The email script used the "Attach File" function and called that same variable as the path: $$InvoicePath . This pulled the specifically named invoice from that folder.
This created an email with boiler-plate body text and other particulars and the specific invoice attached.
The one funtionality I did not achieve with this was to have that invoice document saved on a networked folder so that all users would place their invoices in the same folder. My "work-around" for this is to have them move the entire contents of the "Invoices" folder to the network drive at the end of the day. One could use an automator script or batch file for this to be automated, but that would need to be set up on each workstation.
"When I turned on compatibility view, save as PDF greyed out for server, but it does, actually work for me."
Actually; no. You didn't write a server script. You wrote on conventional script run by the user.
A server script is one that is run by the server, with no user interaction, according to a schedule set up on the server.
1 of 1 people found this helpful
You could have set up the system to use FileMaker container fields. Then the invoices would be immediately available to all users. No need to export to the user's desktop, no need for automator, no need to wait.