Let ( [
CTS = Get ( CurrentTimeStamp ) ;
TS = Year ( CTS ) & Right ( "00" & Month ( CTS ) ; 2 ) & Right ( "00" & Day ( CTS ); 2 ) & Right ( "00" & Hour ( CTS ); 2 ) & Right ( "00" & Minute ( CTS ) ; 2 ) ;
Path = Get ( DesktopPath ) & TS
I'm not sure about your custom function "GetPath", but the Get (DesktopPath ) is a native FileMaker function.
If this doesn't work, then you can check on permissions. However, something is really weird if you as the user do not have permission to write to your own desktop.
FYI, if you want to manipulate files and folders (e.g., copy, paste, delete, move), there are quite a few plugins that do it. I personally prefer the ScriptMaster one because the license is free, but it does involve opening a ScriptMaster file to determine which functions you want to turn on. I usually do this in a Startup script so it is automatic.
Let us know how if this works or not.
Ooops, forgot that you set the calculation above (Let statement) = to a variable say $FullPath. Then you do a:
Save Records as PDF ["$FullPath"; Records being browsed]
GetPath is just a wrapper around the FM Get functions for desktop, file, documents, etc... and when run, will return the following:
Which is the full path to the folder where I want to save the files. Then I create the directory and open the permissions using the Perform AppleScript script step:
"do shell script " & Quote ( "mkdir " & $Path & "; " & "chmod 777 " & $path )
Finally I append the actual file name to the end of the $path and append the "File:" or "MacFile:" either one but neither works.
"FileMac:" & $Path & "/" & Substitute ( $Name ; ", " ; "_" ) & ".pdf"
And this will produce something like:
So, all the parts and pieces are there to do it without a plugin, it just isn't working as expected. One of the thoughts I had is with the new Mountain Lion and Sandboxing, if that could be an issue, but I just don't know.
I like the data viewer for actually testing and seeing each step of what's going on.
If you say it is creating the folder, make that $$file and "watch" the value.
That way you can know the "full path" is exactly what you expect and you might have found a "new feature".
The other way, with a free plugin, just to test is to try the excellent BaseElements plugin and see if somehow the "do shell script" part is interferring with the save as pdf (I couldn't imagine why).
Very frustrating, good luck.
I still suggest trying it with the Get ( DesktopPath ) like I suggested and let me know if that fails too since it is the standard FileMaker script step. But it is up to you. When things don't work as expected, it is good to try lots of different ways to achieve the solution.
I've done it both ways now, with my GetPath CF and with Get ( DesktopPath ). The data returned in the Data Viewer is slightly different.
GetPath : FileMac:/Volumes/Master/Users/jesse/Desktop/Royalties_201208051446/Doe_John.pdf
Get( DesktopPath ) : FileMac:/Master/Users/jesse/Desktop/Royalties_201208051446/Doe_John.pdf
You can see that my wrapper function starts with /Volumes and that is necessary for the shell script in order to create the folder. So, I set the $Path again with the FM built-in function. I get the same results.
There is no indication in your post whether you are using FMServer, but if you are then you must have fmserver permissions set to read and write for any folder you want to save anything to.
The filemac format is what is needed if you want to use a FileMaker function like Save As PDF. I understand external functions like AppleScript and some functions in 3rd party plugins like it the way the OS gives a path, but the Save As PDF is a FileMaker function and that is why I recommended using Get ( DesktopPath ).
Regarding permissions, can you do this on another computer? It is very rare for a User of a FileMaker client not to have write permissions to their Desktop path unless the destination path already has a file in that location with the same name and it is locked (e.g., open or in use). Are you sure you don't have it open in something else? Try changing the name to a new name (e.g., add a timestamp in the name path) and see if it works. And of course if this is being run as a server script, I assume you know that files paths are all different than for a client, but I'm assuming not.
Give those a try and report back.
I have been using create dir, and clone ( or in the old days copy) file set, zip archive and remove originals , to various destinations for a few years.
2 paths are needed
if you are working on different partitions, a different path syntax is required for the mk dir as well
A - mk dir to user sub dir
1) create dir under user path
2) using get desktop will parse this, which does not work
and needs to be substituted to:
B - create file etc under the created dir
3) under user path, single partition
or to desktop
for multiple partiions add /Volumes prefix ( subs
Substitute( $_bup ; ["/Volumes" ; ""] ; ["/volumes" ; ""] ) & "/"
// subn case sensitive
C - and add the path prefix and file suffix
Get ( SystemPlatform ) = 1; "filemac:" ;
Get ( SystemPlatform ) = -2; "filewin:" ;
F = Get ( FileName )
F & ".fp7"
F = $_file ;
FP = $_bup_path
$_platform & FP & F
I was only doing a print pdf to desktop script last night
Note that the FM prefix
to parse paths for checking, one can use terminal and just drag the tergate onto the terminal window to get the path
I like the chmod include in the mk dir btw
No, not on server, so that possibility is out. I'm just stumped. Could I ask for a very simple example file. Have a script create a folder on the desktop and save a record as a pdf. If that works then I know it's something with me and I'll go through it again. If not then some external problem exists and I can try to track that down. Thanks for all the help and here's to hoping solving the problem...
simple demo as requested, note for user on normal single partition
set the var $_volume value to your use case
#SPECIFY THE VOLUME NAME
Set Variable [ $_volume; Value: "/cortex" ]
Set Variable [ $_dst; Value:Substitute( Get ( DesktopPath ) ; $_volume ; "") & "dst"
Set Variable [ $_pdf_path; Value:Get ( DesktopPath ) & "dst" ]
Set Variable [ $_file_name; Value:"abc" & ".pdf" ]
Set Variable [ $_path; Value:"file:" & $_pdf_path & "/" & $_file_name ]
#CREATE DIRECTORY - DST
Set Variable [ $_shellCmd; Value:"mkdir " & $_dst ]
Set Variable [ $_script; Value:"do shell script \"" & Substitute($_shellCmd ; ["\"";"\\\""] ) & "\"" ]
Perform AppleScript [ Calculated AppleScript: $_script ]
#CREATE PDF IN DST
Save Records as PDF [ File Name: “$_path”; Current record ]
[ Document - Compatibility: Acrobat 7 and later ]
[ Pages - Number Pages From: 1; Include: All pages ]
[ Security - Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ] [ Initial View - Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ]
[ Restore; No dialog ]
Exit Script [ ]
demo_dir_pdf.fp7.zip 6.8 K
Looks good other than I disagree that using Get ( DesktopPath ) doesn't work. It may not work with a non-FileMaker function likein an AppleScript, but it clearly does with a FileMaker function like Save As PDF and I've done many a solution with it. I also have to work in a mixed environment most of the time, so I really do all that I can to avoid AppleScripts. And with plugins like ScriptMaster, there are few things for which I need something outside of FileMaker to solve my problems with file/folder functions such as copy, move, delete, zip, etc.
Attached is a file I made on Mac OS X 10.7.4 and FileMaker 12v2. I ran the script and it make the file.pdf report on my desktop. Worked without a hitch.
But I still do not know the answer to the original problem other than maybe permissions or there is a file already in that location or the file is locked by being open or something.
@taylorsharpe Thanks for the test file, but I am still using FM11. Can I still use this file?