Jump to content

Script for Save to Path


This topic is 2815 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

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

Link to comment
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.

 

Link to comment
Share on other sites

  • Newbies

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

Link to comment
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
Link to comment
Share on other sites

  • Newbies

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

Link to comment
Share on other sites

This topic is 2815 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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