steigrafx Posted March 12, 2013 Posted March 12, 2013 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
MartieH Posted March 12, 2013 Posted March 12, 2013 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
steigrafx Posted March 12, 2013 Author Posted March 12, 2013 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
bcooney Posted March 12, 2013 Posted March 12, 2013 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)
steigrafx Posted March 13, 2013 Author Posted March 13, 2013 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
doughemi Posted March 13, 2013 Posted March 13, 2013 Is the Invoice_Date field an actual date field, with slashes?
Rick Whitelaw Posted March 13, 2013 Posted March 13, 2013 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.
steigrafx Posted March 13, 2013 Author Posted March 13, 2013 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
IdealData Posted March 13, 2013 Posted March 13, 2013 The date has "/" characters in it - these have the same effect as using subfolders in the file path, hence the failure.
bcooney Posted March 13, 2013 Posted March 13, 2013 Good catch. Yes, you need to substitute out the slashes for underscores. Also, use Get(TemporaryPath) rather than hardcode the prefix.
steigrafx Posted March 13, 2013 Author Posted March 13, 2013 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.
IdealData Posted March 13, 2013 Posted March 13, 2013 How do I change the slashes to underscores? Look at the Substitute function.
doughemi Posted March 13, 2013 Posted March 13, 2013 Set Variable[$urldate; Substitute(MAS Invoices::Invoice_Date; "/"; "_")] Set Variable[$filename; $urldate & MAS Invoices::Invoice_No & ".pdf"]
steigrafx Posted March 13, 2013 Author Posted March 13, 2013 Thank you, IdealData and doughemi. I was in over my head on this one, and doughemi's variables work perfectly. Thanks again, Kevin
steigrafx Posted March 14, 2013 Author Posted March 14, 2013 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
bcooney Posted March 14, 2013 Posted March 14, 2013 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.
steigrafx Posted March 14, 2013 Author Posted March 14, 2013 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
Recommended Posts
This topic is 4623 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 accountSign in
Already have an account? Sign in here.
Sign In Now