Jump to content
Sign in to follow this  
Nasho23

Script for Save to Path

Recommended Posts

I hope I am allowed to post here for FM11 Pro Advanced on Win 7. I am struggling with the Code shown below. (mainpath = location statement for $filespec)

ROT is the Destination Folder on my Desktop. After Final Testing, the Destination Folder will be elsewhere on my PC.

I need to Save Records as pdf to the Location Path on my PC, to "mainpath" Location with the Filename "Service_Web_120716.pdf"

I have chosen this method, so that I can easily change the Location Path to that required on other Operators machines.

The remainder of Code has tested OK - It is only Destination Path Location that is causing issues.

Error produced is::: Service_Web_120716.pdf could not be created on this Disk. Use a different name, make more room on the disk, unlock it, or use a different disk. There is no problem with the disk; In fact earlier when testing with the Function Get (DesktopPath), the resulting file would show on the Desktop. Now no file on Desktop and Error.

 

$filespec

Let ( [

    mainpath = \C:/Users/Owen_2/Desktop/ROT/ ;

   prefix = "Service_Web_" ;

   today = GetAsDate ( Get ( CurrentHostTimeStamp ) ) ;

   dd = Right ( "00" & Day ( today ) ; 2 ) ;

   mm = Right ( "00" & Month ( today ) ; 2 ) ;

   yy = Right ( Year ( today ) ; 2  ) ;

   filename = prefix & dd & mm & yy

   ] ;

   "file:" mainpath & filename & ".pdf"

)

Save Records as pdf [No dialog; “$filespec”; Records being browsed]

Regards

Nasho23

Share this post


Link to post
Share on other sites

First, what you posted is not a valid Filemaker expression.

Next, file:\C:/Users/Owen_2/Desktop/ROT/Service_Web_120716.pdf is not a valid Filemaker path - see: http://www.filemaker.com/help/15/fmp/en/#page/FMP_Help%2Fcreating-file-paths.html

See if this works for you:

Let ( [
dir = Get ( DesktopPath ) & "ROT/";
prefix = "Service_Web_" ;
now = Get ( CurrentHostTimeStamp )  ;
dd = SerialIncrement ( "00" ; Day ( now ) ) ;
mm = SerialIncrement ( "00" ; Month ( now ) ) ;
yy = Right ( Year ( now ) ; 2  ) ;
fileName = prefix & dd & mm & yy
 ] ;
"file:" & dir & fileName & ".pdf"
) 

 

Note: I would use YYMMDD instead of DDMMYY, so that the files will be in chronological order when sorted by name.

 

Share this post


Link to post
Share on other sites

Thank you for this. For my Test run, this is great and, to a Novice, you make it look so simple.

However; If and when I need to Save the File to a Folder that is located a number of Folders down on E:/My Documents/My Databases/ROTA/WEBSITE/WEB INPUTS/WEB SITE Member Reports/ - How do I change the Code for Saving to this new location???

Not really concerned about chronological order of sorting as these files change every month, with the old ones being deleted after new ones are uploaded to the Website.

Thank You

Nasho23

Share this post


Link to post
Share on other sites
5 hours ago, Nasho23 said:

If and when I need to Save the File to a Folder that is located a number of Folders down on E:/My Documents/My Databases/ROTA/WEBSITE/WEB INPUTS/WEB SITE Member Reports/ - How do I change the Code for Saving to this new location???

If you want to hard-code the entire path, make:

dir = "/E:/My Documents/My Databases/ROTA/WEBSITE/WEB INPUTS/WEB SITE";

However, using one of the built-in paths is recommended, esp. if you intend to deploy this on other people's systems.

 

Edited by comment

Share this post


Link to post
Share on other sites

Thank you for your assistance in this matter. I have elected to stick with the Function (DesktopPath) & "Folder" which will work on everyone's computer.

For no obvious reason that I could see, I could not get the Hard Coded Path to work. I will not bother with that method.

Many Thanks

Nasho23

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.