Have you seen the script at the end of this thread? Duplicating Bill Of Materials (duplicating portal line items)
This script was not based on the invoices starter solution and even the starter solution is different with different versions of FileMaker, but it does show the basic steps you would need to take to duplicate the Invoice record and then the related set of line items records (which in some versions of the starter solution are in a table named InvoiceData.)
HI Phil. Thanks for the reply. I am using Filemaker 13 Starter solution.
I've tried to use this script.
I really don't know what I"m doing. Any suggestions. I've attached the script I did. This is what I wrote but it's not working.
Take a look at the relationships in Manage | Database | Relationships.
it matches the Invoice ID field of invoices to the INVOICE ID MATCH FIELD in Invoice Data. (For some reason, the developer that created the templates chose to use very cumbersome field names for the match fields.)
Thus, your script should only modify the Invoice ID MATCH FIELD and no other fields. This value should be copied to a variable using the Invoice ID field from the current invoices record.
Thus the third line of your script should be:
Set Variable [ $InvoiceID ; value: Invoices::Invoice ID]
and the 10th line of your script should be:
Set Field [Invoice Data::INVOICE ID MATCH FIELD ; $InvoiceID ]
Your current set tries to modify the wrong field and is missing the calculated result parameter.
When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.
And please use the version of this script that is listed near the end of: Duplicating Bill Of Materials (duplicating portal line items)
The version you appear to be implementing has a potential problem should there be more than one Invoices records in your found set at the time you run this script. The latter version corrects for that issue.
I really don't know what I"m doing.
I agree that you have much to learn. I recommend that you invest in some training resources or tutorials to learn more. Not only will this help you with your database, it will better enable you to understand the examples posted in forums like these.
HI. Thanks for your feedback. I have gotten the invoice to copy but not the line items within.
Any additional suggestions? Thanks!
The Go to Related Record step that I see should result in an error message. It should not specify <Current layout>. Instead, it should specify a layout that is based on Invoice Data rather than Invoices. And your current layout should be a layout based on Invoices or you won't get the invoice duplicated by the Duplicate Record step at the beginning of this thread.
And while it does no harm at the moment, I recommend deleting Line 2 (the first set variable step) from this script as it does not do anything. Line 4, the second set variable step, is correctly positioned to capture the ID of the new variable for use inside the loop to connect the new copies of the line items to the new copy of the invoice. So keep that line but delete the first one.
Here's what I've revised. It's still not working. The invoice duplicates but still not line items.
Note: "It doesn't work" doesn't tell me near as much as "it didn't work when I ran the script this is what happened..." HOW a script fails can be a very valuable clue towards what needs to be changed.
I would think that use of Go to related records would also produce an error message as you should be specifying Invoice Data as the "Table:" in your Go to related record step, not Invoices.
Also, Go to Record/Request/Page [no dialog ; $InvoiceID] is also incorrect.
what you should have is:
Set Variable [$InvoiceRecord ; value: Get ( RecordNumber ) ]
Go To Record/Request/Page [no dialog ; $InvoiceRecord ]
Note that $InvoiceID and $InvoiceRecord are two different values. Get ( RecordNumber ) returns the current record's position in the layout's found set.
Thanks for all you help... I give up. Thanks though.