March 12, 201312 yr 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
March 12, 201312 yr 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
March 12, 201312 yr 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
March 12, 201312 yr 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)
March 13, 201312 yr 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
March 13, 201312 yr 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.
March 13, 201312 yr 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
March 13, 201312 yr The date has "/" characters in it - these have the same effect as using subfolders in the file path, hence the failure.
March 13, 201312 yr Good catch. Yes, you need to substitute out the slashes for underscores. Also, use Get(TemporaryPath) rather than hardcode the prefix.
March 13, 201312 yr 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.
March 13, 201312 yr Solution Set Variable[$urldate; Substitute(MAS Invoices::Invoice_Date; "/"; "_")] Set Variable[$filename; $urldate & MAS Invoices::Invoice_No & ".pdf"]
March 13, 201312 yr Author Thank you, IdealData and doughemi. I was in over my head on this one, and doughemi's variables work perfectly. Thanks again, Kevin
March 14, 201312 yr 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
March 14, 201312 yr 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.
March 14, 201312 yr 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