Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Save records as PDF


monty412@mac.com
 Share

Recommended Posts

Yes. You can use variable. What matters is WHEN you grab this information but the script idea is this:

 

# determine OS

Set Variable [ $path ; If ( PatternCount ( Get ( SystemPlatform ) ; 1 ) ; "filemac:" ; "filewin:" )

# determine desktop location

Set Variable [ $desktop ; Get ( DesktopPath ) ]

# determine full file name

Set Variable [ $fileName ; fieldname & ".pdf"

# combine

Set Variable [ $fullPath ; $path & $desktop & $fileName ]

Save Records As PDF [ restore no dialog ; ... and enter this in the output dialog ...

 

$fullPath

 

Field value can be picked up from button click (as script parameter) or - if you are on the record, just set the variable directly with whatever you wish but you can't use FIELDS in output dialog - only variables so pass everything to variable first.

Link to comment
Share on other sites

Thanks LaRetta. It seems to be working well. I'm a little unclear as to the $desktop variable though. I'm monitoring all the variables in the script and nothing happens with it. Nevermind, I figured it out. Thanks again.

Link to comment
Share on other sites

BTW, I was typing quickly and using file name so much that I might have misconstrued part of it ...

 

when I said fieldName, I meant insert your field name containing the value you wish not typing the field name. I probably should have said theField. This is the line which might be misinterpreted:

 

Set Variable [ $fileName ; fieldname & ".pdf" ]

 

and I see I left the closing bracket off that line above as well. smiley-laughing Sheesh, a couple of them ...

Link to comment
Share on other sites

I was okay with the fieldname. I think I had a typo with in the $desktop parameter. One of the problems I had was a discrepancy between the online post and the email response. In the email response the Save As PDF line used $$fullPath instead of the $fullPath that was shown in your online response. After that fix all was well.

Link to comment
Share on other sites

the email response the Save As PDF line used $$fullPath instead of the $fullPath

 

Many people do edits after they have posted (I know I do!) so it is always advisable to check in at the forum to read the post. :)

 

kjoe

Link to comment
Share on other sites

Thanks kjoe, yes, that's the $ correction I mentioned that I fixed (typo).

 

In truth, I set $$ variables to path and desktop in startup script (and many other static User settings) and then just call them within different scripts. It saves setting those variables over and over within each pdf or excel script. Only the filename variable is actually set within the script when it runs.

Link to comment
Share on other sites

  • 6 months later...

i am having a problem with this:

 

Set Variable [ $desktop ; Get ( DesktopPath ) ]

 

doesn't like $desktop, says it can't be used.

 

Could you further explain Set Variable [ $fileName ; fieldname & ".pdf" ]

 

would it look like this? $fileName; company & ".pdf" I'm confused if I need to put in the actual file name.

 

"In truth, I set $$ variables to path and desktop in startup script (and many other static User settings) and then just call them within different scripts. It saves setting those variables over and over within each pdf or excel script. Only the filename variable is actually set within the script when it runs."

 

Can you break down your start up script and then the trigger that makes this work.PDF's are driving me crazy and it sounds like you got it figured out.

 

Thanks in Advance

Link to comment
Share on other sites

Set Variable [ $desktop ; Get ( DesktopPath ) ]
When you click 'Specify', you enter it as follows:

 

In Name: $desktop

In Value: Get ( DesktopPath )

Could you further explain Set Variable [ $fileName ; fieldname & ".pdf" ]

would it look like this? $fileName; company & ".pdf" I'm confused if I need to put in the actual file name.

I should not have used $FileName in that way. To me, FileName implies the name of the FM file. In this instance, I meant it to be the name of the resulting PDF file. But here are a few examples and I'll try to be more clear:

 

If you are on an Invoice and you want to save a pdf of that invoice and name the pdf file the customer's name (dynamically), the 'field' would be your CustomerName field. To designate text, it must be surrounded with quotes; otherwise, FM will think you mean 'grab the contents of the field indicated'. So if you have a CustomerName field and type just CustomerName here, FM will grab and use the CONTENTS of the field in that pdf file name. Syntax would be:

 

Name: The variable which will store the value indicated below

Value: Either a field name, text or calculation

 

So ...

 

In Name: $FileName

In Value: CustomerName

 

... will create a variable which can be called later in the script (during Save As PDF) and that variable will hold a dynamic value which will change depending upon which record you are on. This produces a fully dynamic script which will change depending upon the Customer's invoice BUT ... is generically named $FileName so it can be used all the time (no need to hardcode it; in fact you can't).

Can you break down your start up script and then the trigger that makes this work.
Create a Startup script with the following lines:

 

Set Variable [ $$path ; If ( PatternCount ( Get ( SystemPlatform ) ; 1 ) ; "filemac:" ; "filewin:" )

Set Variable [ $$desktop ; Get ( DesktopPath ) ]

 

Then go to File > File Options and, on Open/close tab, check Perform Script and select this Startup script. THIS is the trigger. Now whenever a User opens their client version of FM, THEIR settings will be stored globally for the duration of their session (because variables are like globals - they are based upon each User). This only needs to be once (upon open) and then these values will be available all through that User's routine - just call them whenever you wish.

 

To summarize: Since you've captured path and desktop already, you don't have to keep adding those lines every time you write a Save As PDF or Save As Excel process (it saves you time). And it saves a nanosecond when executed because every script-step takes time. Those values float above the User always available to use for ANYTHING they may need. This is for your default preference of where that User's documents should be stored. My Users like their folders on their desktop; otherwise they get lost in nav through layers. So these two settings store; then each script (depending upon the need) adds the FOLDER at the end to specify which folder will hold each specific document.

 

Whew! I know ... but it is easy once you figure it out - it'll be a head-slap; it was for me. In fact, I currently use my forehead as a level - it's perfectly flat nowadays. smiley-smile

 

LaRetta

Link to comment
Share on other sites

thanks.....

 

 

cool i think i'm getting there, the files go where i want, but my files keep getting named the variable name ie:$fieldname, not the value...

Link to comment
Share on other sites

Wow. There are so many ways to go. In our case, Owner only can determine where documents are stored. He has a field in Preferences called DefaultDesktopFolder in which he's placed the text FM Folder. Each desktop has this folder on it. Then my startup script includes:

 

Set Variable [ $$DefaultFolder ; Preferences::DefaultDesktopFolder & "/" ]

 

Then your pdf creation script would be changed to:

 

Set Variable [ $$DesktopPath ; Get ( DesktopPath ) & $$DefaultFolder ]

 

Why do I have these in pieces instead of just one path listed? Unknown. It seems every time I attempt to be clever and combine some things, then I need to split them later. I wouldn't want to include the folder in same string because we may want to store documents in different folders in the future depending upon the base table or privilege set or ?? Contingency.

 

BTW, I've heard from a highly reliable source that testing the platform and setting with filewin or filemac isn't necessary (but I might have only dreamt it also). Since I haven't had a chance to test it xplat, I'm hesitant to remove it from my file until I'm sure.

 

Depending upon business rules of course, Users could also define their OWN folder default location and can change it to the new folder (after creating the new folder). Much depends upon backups in place (which User folders are included in network backups), permissions and such. It would be very easy to do ... put the DefaultDesktopFolder field in their User Preferences (Staff table) and load your Startup script from there instead. In this way, if they change where they want their documents stored, they can change their own preference to the newly created folder name. Be sure they understand the change will not take affect until their NEXT user session (when that Startup script executes next).

 

As I've said, there are too many options to give one which would fit your need without knowing your need but I hope this gives you ideas to work with. smiley-smile

 

UPDATE: ah, that green accidental smiley is so darned cute that I don't have the heart to remove it. I think everyone knows what it says anyway.

 

LaRetta

Link to comment
Share on other sites

  • 1 month later...

With the help of this site, I got my filemaker database to successfully create a PDF on my desktop and email it to my intended recipients. This works flawlessly from my desktop, however after I had IT add the database to our FIleMaker Pro server, the PDF now gets saved in my FileMaker Pro appliction folder and the email contains not attachement. Anyone know the key to this one?

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

 Share



×
×
  • Create New...

Important Information

Terms of Use