Change it for just the current invoice or for all future invoices as well?
To just alter it for the current invoice would require using a script that modifies the value in the discount rate field in each Invoice Data record linked to the current invoice. If you add a field to Invoices to use for specifying the new discount rate, you can:
Use Go To Related Records to bring up the related invoice data records on a layout based on Invoice Data
Use Replace Field contents with the no dialog and calculation options selected to replace the value of the Invoice Data::Discount Rate field with the contents of the new field you just added to invoices.
Return to your original layout.
I have tried, this but it's not working.
The invoice table "Invoice" is using another table "Data invoice" to fill the lines in it. As defined in the sample provided by FMP.
Unless you have modified the design, the table is called Invoice Data and the script I have outlined will work for this.
What part of it is "not working"? HOW is it not working?
Nothing is working, I have 7 lines in the invoice and none of them are modified.
Thank you for your help.
Please post the script that you have created.
To post a script to the forum:
- You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
- You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here.
- If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
- If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
Here you go, really simple.
Better in english!
You left out a step:Use Go To Related Records to bring up the related invoice data records on a layout based on Invoice Data
And don't forget that you need a field in invoices for specifying the discount rate that you want to apply to all items in the portal.
If [ Not IsEmpty ( Invoice Data::Invoice ID match field ) // make sure that line items records actually exist ]
Go To Related Record [Show only related records; From table: Invoice Data; Using layout: "Invoice Details | iPhone" (Invoice Data) ]
Replace Field Contents [
Go To Layout [Original Layout]
Note: I specified "Invoice Details | iPhone" here, but any layout based on Invoice Data may be specified and this will still work, just make sure that there are no script triggers being tripped by the layout change that would interfere with this script.
An alternative method is to define a calculation in Invoices that applies the discount rate you specify to the invoice total as a whole instead of each individual line item.
I though that because I was already in the right table, right layout with right record, all I had to do was to add this script to a button on the invoice layout.Thank you from the beginner I am!
You weren't on the "right layout" and thus were not on the "right table". This script changes context from Invoices to Invoice Data in order to make the needed "batch update" of your line items.