Duping a Record With All Its Related Portal Records Intact - File Maker

On the CD-ROM: In the Stack Select Dupe folder.
Primary Database: Solution.fp5, layout THREE.
The Problem: Tons of in-house developers and intermediate users request this feature, because they can’t figure out how to do in on their own. They want to duplicate an invoice or purchase order with a button that also duplicates all associated line items and (sometimes) contacts for that respective document, when there’s more than one contact. Usually, users can’t figure out how to do this because they don’t have experience using global fields or constant relationships, or they’re not too handy with the ScriptMaker even though you all know that the ScriptMaker can be a close, lifelong companion.
This solution will put all of those questions to rest at last.
The Solution: Setting up this technique is trivial. Once you’ve set up a constant relationship, all you need to add is two scripts, one in your Line Items database, the other in the Invoice (here called Solution.fp5) database.

The script in the Line Items database (called, in the sample databases, Support2.fp5) consists of several simple steps. First, the window is frozen; then Browse mode is invoked. The Layout #1 layout is invoked, and you are taken to the first record in the found set, then the gRecordNumber field is set to the record number of the first record in the set.

Next, you enter a loop where, cycling through every record in the found set, you dupe the record, set the InvoiceID of the record to the ID of the newly created master InvoiceID just created in Solution.fp5, and then omit the record. Then you go to the next record in the found set, set the gRecordNumber field again and continue through all the line items until all are duped. Then you exit the loop.

The script in Solution.fp5 is just about as simple. First, you enter browse mode and isolate the current record that you want to duplicate into a found set of one. Next, you go to related records (show only related records) to isolate the line items that you want to duplicate, then duplicate the record. After that, you set the g Invoice ID to the newly created Invoice ID so as to transfer the value to your newly imported line items.

Once you’ve performed the related script created above in the Line Items database, you’ll probably want to add an Exit Record script step to make sure the user is left in the Invoice database, rather than Line Items. Or add in a Show All Records step like you did here. And you’re finished


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

File Maker Topics