Save PDF to filepath

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:

What am I doing wrong?

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)

1 Like

In Windows you need a prefix of ‘filewin’ not ‘file’.

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 was under the impression you could use the relative file path also?

file: certainly works if importing from another file on a hosted server, or if the file is to be saved relative to the current file.

However, in this case the full path was specified and it requires filewin:


This is useful: Creating file paths


So sadly, filepath returns the path AND the filename. filename obviously returns just that... curious to know why the path doesn't just return the path and not the entire thing.


Also curious (or perhaps not), in my script, I tried to concatenate using this:

"c:" & Venues::VenueName & "~" & GIGS::Date & ".pdf"

Filemaker said it couldn't find table ~ which I thought was strange. If I take "c:" off, the variable sets, I don't get the error.

Since I can't seem to figure out how to set the path, I'm just hard coding the location to the desktop.

I saw suggestions for running this on a server, but a) I don't have one, and b) long-term this solution would be mobile on a laptop anyway.

Why do you add "~" in the path/filename ? This does not seem to be a forbidden character, but I wonder if that will work.

If you look at $FileLocation, there is a space in the file name, it will not work unless you quote the path and file name.

On top of that, you have to make sure that the file will be created in a directory where FileMaker can write - have the permissions.

1 Like

At the risk of pointing out the obvious there is a missing ‘/‘ after ‘c:’


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.

tilde is a shortcut to the users home directory on many unixoid operating systems, it should be used with caution or better be avoided in filepaths


@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 have a theory that, instead of precisely what is posted above, @cpking might have actually tried a calculation similar to:

"c:\" & Venues::VenueName & "~" & GIGS::Date & ".pdf"

Note the errant backslash after c:

The above would have been a very understandable mistake:

  • One means to type a forward slash, but instead types a backslash.

The likely consequence of such an error:

  • The backslash would escape the quote char that directly follows it.
  • Consequently the literal string intended to enclose "c/:" is not closed, and does not close until the quote char just before the tilde.

If all of the above were to happen, it would place the tilde char outside of any quoted string.

This would result in the FMP calculation parser attempting to resolve the tilde as a schema reference.

Upon finding no schema matching a tilde char, the likely error message from the FMP calculation parser would be "Can not find table ~".

I've been playing with the script, and managed to create the pdf on the user's Windows desktop.
Script is:

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.

Try Get (FilePath).