Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Is there a script or set of options that allow me to Save a Records as PDF with a specific file name? I would also like the file to go in a specific folder ? What kind of line should I include in my script ?

For example, when I create an invoice, I want the file name to be the invoice number from the InvoiceID field and that file to go to my Invoice folder...

Thanks for your help !!!

Posted

You can use variables to name files and even specify their paths. I store default paths in Preferences file and load my global variables in starup script (with platform and path) but here's example of generic, storing to desktop:

Set Variable [ $platform ; Case ( PatternCount ( Get ( SystemPlatform ) ; 1 ) ; "filemac:" ; "filewin:") ]

Set Variable [ $path ; Get ( DesktopPath ) ]

Set Variable [ $FileName ; InvoiceNumber & ".pdf"

# Then combine them into one string

Set Variable [ $FullPath ; $platform & $Path & $fileName ]

# Then save your file

Save Records As PDF [ Restore, no dialog; $FullPath; Records being browsed ]

Posted

I'm totally new to the whole scripting and don't really understand what I do. Here is the script I have in place:

Go to Layout ["Invoice Layout" (Invoice)]

Set Variable [ $platform ; Case ( PatternCount ( Get ( SystemPlatform ) ; 1 ) ; "filemac:" ; "filewin:") ]

Set Variable [ $path ; Value:Get ( DesktopPath ) ]

Set Variable [ $FileName ; Value:Invoice::InvoiceID & ".pdf"

Set Variable [ $FullPath ; Value:$platform & $Path & $fileName ]

Save Records As PDF [ Restore, no dialog; $FullPath; Records being browsed ]

When I run the script, I have the following Error message

392934.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

What am i doing wrong ?

Posted

I can't say - I've never received that error. Open Data Viewer and run debugger on it. What does it show as $FullPath? Are there any invalid characters, such as />"? Do you have pdf installed on that system? Everyone should have privileges to save to their desktop.

Posted

To clarify, that error usually indicates a file is read only; readily obtained when one saves a file on CD. But you are creating a file so it makes little sense. The error indicates you can't save to your local hard disk and that doesn't make sense either.

Posted

how do i specify the directory then ?

I assume it is in the Path line but how ?

In that line, I chose Set Variable.

the options came up and I typed

$Path for the Name

Get ( DesktopPath) for the Value

1 for the Repetition

Do I have to specify the directory path in the value ? if so, how ?

Posted (edited)

Thanks, Michael.

Okay, try this: Create a global text field. Disable to Save to PDF line and add this:

Set Field [ thatGlobal ; $FullPath ]

Then copy/paste the line [color:green]data value in the field here for us to see.

[color:green]Your script is a copy/paste of mine. I doubt your script looks exactly the same? Something is off somewhere because Get(DesktopPath) should work and Windows always has a desktop path folder.

Edited by Guest
Added green
Posted

I re-created your error. Yes, there is something probably wrong with the Directory name. I have never known Windows not to find its desktop. :crazy2:

Are you appending to add a sub-directory? If so, the directory name must end with / and that might explain the problem.

Posted

I think it gets kinda funny...guess what guys ?

After all the good advices you guys gave me, I decided to restart my computer and the script works !!! I WILL NEVER GET COMPUTER.

However, I need your help on 2 more thing, the script will save the PDF file on desktop...I'd like to save it on D:BusinessInvoice

How do i do this ?

Then, the script is for a button on a portal included in the customer layout and i want the script to make the invoice for the specific portal record...what line of script should i include ?

Posted

D:BusinessInvoice

You can read up on it in help. Your string will need to look something like:

filewin:/D:/Business/Invoice/InvoiceNumber.pdf

Again, I wouldn't hardcode the path but store it as data and load global variable at startup then reference it via script as needed. In this way, if you change the folder name or location, all your files will store consistently in same place and you won't be modifying all your scripts.

Script on button in portal row would look something like:

Freeze Window

Go To Related Record [ Show only related records from Invoices using Invoice layout ]

...your pdf script portion

Go To Layout [ original layout ]

Posted

Just change the value of the variable from the Desktop Path function to your directory that you want.

Set Variable [ $platform ; Case ( PatternCount ( Get ( SystemPlatform ) ; 1 ) ; "filemac:/" ; "filewin:/") ]

Set Variable [ $path ; "D:/Business/Invoice/" ]

Set Variable [ $FileName ; Value:Invoice::InvoiceID & ".pdf"

Set Variable [ $FullPath ; Value:$platform & $Path & $fileName ]

Posted

I am not sure the 'filemac/filewin' part is required when saving a file. A path defined as:

Get ( DesktopPath ) & "/" & Table::Filename & ".pdf"

works just fine for me.

Also, I don't quite see the advantage of assembling the path piecemeal, with intermediate variables. As LaRetta says, I would put the path to the directory in a global field, then:

Set Variable [ $path ; Table::gPath & Table::Filename & ".pdf" ]

Save Records as PDF [ File Name: “$path”; Current record ]

Posted

No arguement here. I completely agree with you and would also use a global field to store the path as well. When I posted, I had not seen Laretta followup post. I was just trying to display it for malagasy to see that the path can just be easily changed if he didn't want to use Get ( DesktopPath ); still using the steps in Laretta's first post.

As for not using 'filemac/filewin', he should use it because he isnt using Get ( DesktopPath ), no?

Posted

As for not using 'filemac/filewin', he should use it because he isnt using Get ( DesktopPath ), no?

I don't think so. The result of Get ( DesktopPath ) does not include 'filemac/filewin', so using it or not should not matter. I think the distinction between 'filexxx:', 'imagexxx', 'moviexxx' may be significant when bringing files into Filemaker, but not in the opposite direction.

Posted

Cool! I hope they add support for additional movie formats i.e. mpeg... in fm9 -- though i suppose you could get away with using the webviewer..

Posted

QuickTime can usually play a MPEG movie, at least on a Mac. This is a very complex subject, so let me just say that QT is not really a format - more like a platform. I am not sure Filemaker controls what QT does or doesn't. I think it's an external resource, just like the web viewer.

Posted

Hmmm, I don't like the quicktime software itself the whole paying for standard features that come in the "pro" version kind of puts me off, and I suppose the bigger issue is really that it doesn't ship with windows as standard, I'd prefer that on windows they just used wmp.

I wonder if you could get away with just installing quicktime alternative... Which plays all quicktime formats as well as mpegs. Either way, i'll try both quicktime and alternative and see what formats it will .. or won't accept.

Thanks for the insight comment.

Posted

Malagasy,

Can you please post the final version of your script that worked? I have tried piecing the posts together for a solution but nothing works.

Posted

In its Simplest form there are basically two steps.

Set Variable [ $path ; "filewin:/D:/Business/Invoice/Whatever.pdf" ]

Save Records as PDF [ File Name: “$path”; Current record ]

However, in the examples that were posted above, it was demonstrating how to do it without hard coding the path or the filename that you want to save the PDF as. You can reference a field for those if you wish.

Posted (edited)

If you need to store the PDF in a specific folder, you need the following line of scripting:

Set Variable [ $Path ; "filewin:/D:/Business/Invoices/"]

Make sure you don't forget anything such as / ...

If you want the file saved to have a specific name, you also need a line such as:

Set Variable [$FileName ; Invoice::InvoiceID]

Hence, this 2 previous line need another line such as:

Set Variable [$FullPath ; $Path & $FileName]

At the end your script should look like this >

Set Variable [$Path ; "filewin:/D:/Business/Invoices/"]

Set Variable [$FileName ; Invoice::InvoiceID]

Set Variable [$FullPath ; $Path & $FileName]

Save Records as PDF [ “$FullPath”; Current record ]

This one works for me, let me know if you have any problems...I can try to help.

David

Edited by Guest
  • 4 weeks later...
Posted (edited)

hello i am having trouble that has cost me hours, if i use

Set Variable [ $path ; Get ( DesktopPath ) ]

Set Variable [ $FileName ; InvoiceNumber & ".pdf"

i get the errors stated above "cannot write to disk" now if i use any other field to save by it works. i think the problem is with my invoice and purchase order numbers.

PO[color:red]:1024

PO[color:red]:1025

PO[color:red]:)1026

or invoice

inv[color:red]:1024

inv[color:red]:1024

so these characters are messing things up because if i pick another field it works, [color:purple]can i escape these characters in the script.

Thanks

RT

Edited by Guest
Posted

Set Variable [ $path ; Get ( DesktopPath ) ]

Set Variable [ $FileName ; Substitute(InvoiceNumber ; ":" ; "-" ) & ".pdf"

Posted

"filewin:" & Get ( DesktopPath ) & invoice::filename & ".pdf"

is what you want to use, but because of the colon, you are only going to be able to get files called PO or INV. The rest of the fiel name will be chopped off. Do not use the colon because it means something in paths. Try the underscore _ instead.

Posted

thank you both for your answers. i went with Genxs solution and it works.

  • 2 months later...
Posted

it's important to remember that the path parsed by Filemaker must use "/" as the delimiters for Windows paths and not "". If you are using TRFile for example to capture paths, it will capture using "" and after you capture the path, you should do a Subst on it to swicth the to /.

This resolves the 'can't save to disk error', too.

This topic is 6443 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.