From Dwayne Wright PMP
Certified FileMaker Developer
Please Note: If you are viewing this page in a news feeder, the images may get munged up a bit or other formatting of the posting may fail. For the best experience, please visit the journal directly by clicking (here).
Although this is a pre-FileMaker 7 example, I continue to have people request it. I was able to dig it up from the archives and post it here. It does show some interesting techniques but could use some updates such as employing script variables.
Here I show how you can copy a portal row and paste it into a new portal row. We do this by using a script and a few FileMaker text functions to concatenate and parse a global field.
Here are the basic steps we took ...
- Created the two files and defined a relationship between them using the state field
- Made sure the relationship allowed us to create new related records
- Added the portal to the layout of the parent file and made sure it had a vertical scroll bar
- Created a global field to hold all the contents of the portal row
- Set the global field equal to the contents of the portal row
SET Copy Portal Row Global - child::Company & " | " & child::Contact & " | " & child::Phone
so here we used a calculation to concatenate each of the fields in the portal into one field. We separated the data in each field by putting a text string " | " between them. This gives us a marker of where the data in a field starts and ends. You can see how this works when you click the Copy Row button in a portal row.
- Next we added a button to the first portal row. This button will appear in all the available portal rows to perform the script we just created. I used a merge field from the child file so that the button would only appear in rows that have information.
- I added a delete portal row button to the first portal row but it is not essential to the technique
- Next we created the script to create a new portal row and paste in the information we previously copied. It breaks down into the following steps
GO TO PORTAL ROW - last
** This is how we are creating a new record**
SET FIELD - child:Company
Left(Copy Portal Row Global,
Position(Copy Portal Row Global, " | ", 1, 1))
** This pulls all the text characters left of the first " | " marker**
SET FIELD - child:Contact
Middle(Copy Portal Row Global,
Position(Copy Portal Row Global, " | ", 1, 1) +2,
Position(Copy Portal Row Global, " | ", 1, 2) - Position(Copy Portal Row Global, " | ", 1, 1)-2))
** This pulls all the text characters between the first " | " marker and the second "|" marker. It also trims any leading or trailing character spaces.**
SET FIELD - child:PHone
Trim(Right(Copy Portal Row Global,
Length(Copy Portal Row Global) - Position(Copy Portal Row Global, " | ", 1, 2)-2))
** This pulls all the text characters right of the second " | " marker. It also trims any leading or trailing character spaces.**
- Finally, I added a button to the layout the runs the paste script we just created.
An example file can be downloaded by clicking (here).
More info about the author and FileMaker in general, contact me at firstname.lastname@example.org.
© 2007 - Dwayne Wright - dwaynewright.com
The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.