Jump to content
Sign in to follow this  
MartinaL

PDF save directory - is this possible

Recommended Posts

being able to specify the directory pathway for saving a PDF document and having it automatically given a unique file name based on one or several fields of data in FMP

Share this post


Link to post
Share on other sites

Are you still on FM6? If so then no. If you are on a newer version then you can create the path in the variable then export out the variable path.

Share this post


Link to post
Share on other sites

No I am now on filemaker 10, so how would this work?

Say I run a report for a certain artist and I want it to save into that artists directory on the server with the artists name and the date in the filename, is that possible?

Share this post


Link to post
Share on other sites

First you should change your FileMaker version in your account settings under the 'FileMaker Questions' section.

Second, you can try this.


Set Variable [ $path; Value:"filewin:/C:/" & YourArtist & "/" ]

Set Variable [ $file; Value:YourArtist & "_" & Substitute ( GetAsText ( Get ( CurrentDate ) ); "/"; "-" ) & ".pdf" ]

Set Variable [ $fullpath; Value:$path & $file ]

Save Records as PDF [ File Name: $fullpath; Current record ]

*Edit - added substitute function to swap out forward slashes in date.

Edited by Guest
added substitute function

Share this post


Link to post
Share on other sites

P.S. Your directory named with your Artist will have to exist already. If it does not, then you will have to use a command line command (or you can use a plugin MooPlugin is free) to create the doc path for you.

Share this post


Link to post
Share on other sites

I have a slightly different version of this question. I use a dialog box for the user to enter the PDF's file name, but I need a way for them to select the Save To directory. All the solutions I've see involve the user clicking on a file to get the directory path, but since my users they will type in the PDFs name in the dialog box clicking on a file in the save to directory is confusing. They also need the ability to create directory if it doesn't exist.

Any suggestions? This is for a FMP 9 Windows platform so Apple Script and triggers are out.

Thanks,

Will

Share this post


Link to post
Share on other sites

As my previous post said, you are probably better off using this free plugin

http://mooplug.com/features

Share this post


Link to post
Share on other sites

Hi

Do you have to do a similar thing if you just want the current date to be automatically included in the PDF filename?

cheers

Share this post


Link to post
Share on other sites

See the script in my second post.

Share this post


Link to post
Share on other sites

But ... $file; Value:YourArtist & GetAsText ( Get ( CurrentDate) ) & ".pdf" ]

... unless I'm mistaken and I frequently am, Windows does not like frontslash in the file name. You might want to make it 20090504, for example.

UPDATE: How rude of me ... if you wish 20090504 format, you could use this for the file name:

Let (

today = Get ( CurrentDate ) ;

Year (today ) & Right ( "00" & Month ( today ) ; 2 ) & Right ( "00" & Day ( today ) ; 2 )

)

& ".pdf"

There are many other ways to write the date in text format as well, this is just one example.

Edited by Guest
Added update

Share this post


Link to post
Share on other sites

You are absolutely correct. I had not thought about when dates are entered with slashes. ???

I modified the post to accommodate for the forward slash.

Thanks for finding it and point it out! ???

Share this post


Link to post
Share on other sites

Hi,

I've worked out how to put the current date into the PDF file name with and without hyphens, but is it possible for me to get it into the following format: DDMMYY (australian date format but with last 2 digits of year only).

If I try to use RightValues( year ; 2) it doesn't seem to work...

Share this post


Link to post
Share on other sites

You need to use Right() and not RightValues() but here's another alternate method:

SerialIncrement ( "00" ; Day (date ) ) &

SerialIncrement ( "00" ; Month (date ) ) &

Right ( Year ( date ) ; 2 )

Edited by Guest

Share this post


Link to post
Share on other sites

not RightValues (), you want Right ()

Share this post


Link to post
Share on other sites

Thanks so much for your help, all of that worked perfectly!! If the name field contains the name John Smith, is it possible to just have the initials "JS" picked out? or am I pushing it too much

thanking you in advance

Share this post


Link to post
Share on other sites

You can format the pdf name any way you wish. I don't know how you are pulling the name but it would be something like:

Left ( NameField ; 1 ) & RightWords ( Left ( NameField ; 1 ) ; 1 )

... if the Name field contains John Smith. But your name field should have LastName and FirstName in separate fields.

Share this post


Link to post
Share on other sites

Hi

RightWords(Left(NameField ; 1 ) ; 1)

returns the first letter of the first/left word "J" for some reason. Not sure why, maybe it gets confused.

Share this post


Link to post
Share on other sites

Not sure why, maybe it gets confused.

Nope. I broke one of my own rules ... ALWAYS create a test instead of responding because we all can be a bit side-tracked or in a rush and can thus make a mistake. And I did.

Of course it should be:

Left ( RightWords( NameField ; 1 ) ; 1)

I apologize for being sloppy and in a hurry.

UPDATE: Keep in mind that, if the person's name is Bill Smith, Jr. it will break. This is another reason each part of the name should be in its own field.

Edited by Guest
Added update

Share this post


Link to post
Share on other sites

That's so weird, I thought I had tried to reverse it and couldn't get it to work, but I copied yours and it worked perfectly. Thanks so much LaRetta and to Vodka!

When filemaker works it really is a thing of beauty and I've copied what I did

"Record Royalty Report - " & Left ( Writer1; 1 ) & Left ( RightWords( Writer1 ; 1 ) ; 1) & " - " & SerialIncrement ("00" ; Day (PeriodEnding )) & SerialIncrement ("00" ; Month(PeriodEnding )) & Right (PeriodEnding ; 2 ) & ".pdf"

Share this post


Link to post
Share on other sites

A small thing but I would be negligent not to mention it:

Right (PeriodEnding ; 2 ) & ".pdf"

I see you have bypassed using the Year() function as Right ( Year ( PeriodEnding ) 2 ).

Just keep in mind that, whenever you remove FM's ability to recognize which part of the date is month, day or year, you run the risk that your text calculation might break if you change your system format. Rare in the case of the year, but I want you to be aware of it.

I am not an expert on interpretation of date settings at the OS level but I would err on the side of safe whenever possible.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

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