I am trying to script the creation of a PDF file. I'd like the resulting file to land in the same folder as the database. In Windows 10, I'm using this script. My goal is to create a pdf named VenueName~GigDate.pdf.
but I get this error:
Not sure if the problem is the syntax on the filepath; in Windows, the path is usually "Drive letter:/filename.extension" but data viewer tells me the path being saved doesn't follow that syntax:
Try putting your expression into a single variable and use that for the 'Save Records as PDF' step. It will interpret the contents of a calculation, but it won't evaluate a calculation (a bit like merge variables on the layout).
Also, I'm sure you've heard others recommend this, but consider hosting your DB file on a server. (Not related to your question, but no less important)
Also, I forgot to look at the dataviewer part of your question, but pay attention to the fact that your $$FileLocation var includes the file name. You will need to strip that out when building the path to save the PDF to.
Thank you for providing so much details in your question. It really helps (if I don't skip over it of course!).
I used the tilde because I wanted the resulting filename to be easy to read in a folder. Using a dash would confuse it with the date. A tilde was a legal character that would delineate the gig name from the date.
@cpking If you want to save it in a folder you might want to try using a folder that you have "write" rights to. aka files you own. The user using FMP should have rights to all folders in their home directory. You could also use the temp folder you should be able to write to that.
Other's have pointed out some good things to look at. My hunch is that you are trying to write to a folder you don't have or Filemaker doesn't have write access to.
I've been playing with the script, and managed to create the pdf on the user's Windows desktop.
filewin:$Filelocation/$GigFileName results in the correct filename (i.e., "Erickson Home~10-21-2018").
I'd prefer the resulting file to land in the same folder with the database file, but can't seem to get just the path to the Filemaker database file. This solution at least lands the file in a predictable location.