Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

Save as PDF using multiple field names


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

Recommended Posts

Posted

I've searched but can't find a solution to this problem.

 

I have a script that saves the current record as a pdf.  I'm using a variable called $Invoice_Number with the value

MAS_Invoices::Invoice_No & ".pdf", and this works well enough, but...

 

I would like to add a second field to the file name, MAS_Invoices::Invoice_Date, but I can't figure out the syntax.  The Invoice_Number should precede the Invoice_Date.

 

Thanks for your time and help.

 

Kevin

Posted

MAS_Invoices::Invoice_Date & MAS_Invoices::Invoice_No & ".pdf"

 

if you want something like an underscore between the date and the invoice number, you could do: MAS_Invoices::Invoice_Date & "_" & MAS_Invoices::Invoice_No & ".pdf"

 

should do it

Martie

Posted

Thanks for the reply, Martie.  That's exactly what I tried but it doesn't work.  Running the script on invoice number 2, I get an error saying:

"20132.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."

 

The file saves fine with the script step in my original post, for example, 2.pdf.  I'd like it to be preceded by the date, if possible.

 

Thanks,

Kevin

Posted

That is typically a badly formed path error, Kevin. Do you set $exportPath and then use $exportPath in the Save as PDF script step?

 

Set $exportPath, Get(desktopPath) & Invoice::Date & "_" & Invoice::ID & ".pdf"

Save As PDF ($exportPath)

Posted

Hi, bcooney.  Thanks for the reply.  No, I don't set a variable for the file path.

 

I set a variable for the file name:  $Invoice_Number = MAS Invoices::Invoice_No & ".pdf"

 

and use the variable in the Save Record as PDF, along with the full file path:  filewin:/c:/temp/$Invoice_Number

 

What you see here works perfectly.  When I add a second field to the file name variable, that's when I get the error:

MAS Invoices::Invoice_Date & MAS Invoices::Invoice_No & ".pdf"

 

Is it syntax?  Or am I just going about this the wrong way?

 

Thanks,

Kevin

Posted

Is the Invoice_Date field an actual date field, with slashes?

Posted

Not at a computer at the moment, but I believe you should insert &" "& between your two field names. Otherwise you end up with Table::FieldTable::Field. FM won't understand this. Nor would any other application.

Posted

Thanks for your replies.

 

doughemi:  Yes, it is a date field, with auto-enter creation date, in the format 03/12/2013.

 

Rick:  I did as you suggested:  MAS Invoices::Invoice_Date & " " & MAS Invoices::Invoice_No & ".pdf"

but it didn't help.  I receive the same error.

 

Thanks again,

Kevin

Posted

The date has "/" characters in it - these have the same effect as using subfolders in the file path, hence the failure.

Posted

Good catch. Yes, you need to substitute out the slashes for underscores. Also, use Get(TemporaryPath) rather than hardcode the prefix.

Posted

Yes, that must be the problem.  I substituted a text field instead of the date field, and it worked perfectly.  It's definitely the date.

 

How do I change the slashes to underscores?  Using the inspector, I changed the numeric separator to an underscore, but that didn't work.  Is there somewhere else I should be looking?

 

Sorry to be such a pain.

Posted

How do I change the slashes to underscores? 

 

Look at the Substitute function.

Posted

Set Variable[$urldate; Substitute(MAS Invoices::Invoice_Date; "/"; "_")]

Set Variable[$filename; $urldate & MAS Invoices::Invoice_No & ".pdf"]

Posted

bcooney, quick question.  You told me to use Get(TemporaryPath).  If I do, doesn't Filemaker delete everything when I exit?  I need to keep the pdf's.

 

Thanks,

Kevin

Posted

Well, you did say that you were trying to write the PDFs to "and use the variable in the Save Record as PDF, along with the full file path:  filewin:/c:/temp/$Invoice_Number".

 

It is better to use FileMaker's Get (TemporaryPath), and yes this directory is purged.

 

However, why are you saving PDFs of an invoice? The record is there. Make a copy and it might not reflect the actual state of the data.

Posted

We were using WordPerfect in the past to generate invoices and obviously needed to save copies.

 

I don't know what I was thinking, except to say that "old habits die hard."

 

Thank you for bringing this to my attention.

 

Kevin

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