have you tried:
I am confused. are you trying to capture the date the pdf was created or the date it was added to the container field.
360 Works has some wonderful plug ins that capture information relating to PDF documents which are stored in container fields
I want the date the PDF was created. Yes, doable with a plugin, but I want to avoid the cost & deployment issues of plugins.
As already suggested, a calculation field with GetContainerAttribute ( yourTO::yourField ; "created" ) will give you the earliest timestamp from the file in the container. This will only work, however, if one has been set in the file itself, which is not necessarily the case; if there is no date this will return "?". You would probably need to use something like:
If ( GetContainerAttribute ( aaaaa::container ; "created" ) = "?" ;
"not dated – " & Get ( CurrentDate ) ;
GetContainerAttribute ( aaaaa::container ; "created" )
Please see FileMaker's documentation for GetContainerAttribute. It states that the created attribute only works for photos. If I attempt to get the created attribute of a PDF, it returns ?. Of course if you've found a way around that limitation, I'd be happy to hear it.
1 of 1 people found this helpful
It works, but it's awfully ugly, since it uses Applescript and passes data via the clipboard.
Using AppleScript in and of itself isn't that ugly – but overwriting the Clipboard surely is.
Having said that, create a “throwaway“ (I prefer the wording utility … ) global field and write to it from AppleScript, à la
Set theDate to ( your AS code to read the PDF date )
Tell application "FileMaker Pro Advanced"
set field "gUtility" of table "YourTable" to theDate
Get the correct syntax from the FileMaker AS dictionary – I can never remember if it is field or cell, table or database (all of which are valid object types, just in different contexts …)
You can also write into non-global fields, but I think they have to be on the current layout, or that is hampered by some other limitation …
I accept your correction, but add a correction of my own. Under the heading Photos it adds: "Note Only JPEG and TIFF files return results." I tested this and it is the case. In Photoshop I converted a jpg file into various other formats (PSD, PNG, EPS) none of which returned the Photo data that JPEG and TIFF files do, even though each is also a photo file format.
That works, in most situations, and it's a definite improvement, thank you!
One small change, I ended up using:
"tell app \"FileMaker Pro" & If(contains(Get(ApplicationVersion); "Advanced"); " Advanced") & "\"..."
since most of my users don't have Advanced. I've also sometimes seen Applescript tell the wrong version of an app, if a user has multiple versions installed: Applescript doesn't always choose the version that's running. I don't know how to deal with that, but it shouldn't impact my users (just me, since I keep old versions around for testing).
It also, unfortunately, fails if a modal window is frontmost in FileMaker. If you've got a modal window, the Applescript times out. So it requires some window-juggling (open an identical non-modal window in the same location as the modal window, close the modal window, run the AppleScript, reopen the modal window, close the non-modal window... since FMP doesn't let you change modality of an existing window. Sigh.)
OK, I found a way to do this without needing the Applescript to include a (possibly problematic) Tell FileMaker segment, and without using the clipboard.
1. Turn error capture on.
2. Use an AppleScript to get the creation year of the file; return it as a negative error number.
3. Set a variable to abs(get(lasterror)).
4. Use an Applescript to get the creation month & year of the file; return that as another negative number.
5. Parse the variable and the latest errornumber together to make a date.
6. Set the field.
The error number must be negative, or else the user will see an error message (despite error capture). Year and mo/day must be seperated because 8 digit error numbers produced by an AppleScript read as 0 when you get(lasterror).