Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Save as PDF using multiple field names

Featured Replies

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

Solved by doughemi

Go to solution

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

  • Author

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

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)

  • Author

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

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

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.

  • Author

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

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

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

  • Author

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.

How do I change the slashes to underscores? 

 

Look at the Substitute function.

  • Solution

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

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

  • Author

Thank you, IdealData and doughemi.  I was in over my head on this one, and doughemi's variables work perfectly.

 

Thanks again,

Kevin

  • Author

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

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.

  • Author

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

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.