The theory in that is fairly sound - However I ran into a few problems:
1) When I performed the search (using a brand new database I created with the exact same tables, records and everything), it just showed me all of the Contacts, as opposed to only the ones that matched the name I typed in.
2) Once I get that to work - your idea is great - but I would like to be able for it to be a little simpler in terms of showing me the results. I don't want to have to pull the user too far from where they're currently performing the find. Can I make the results pop up in an embedded field in the initial layout I'm performing the find? (In your example, it would be like having the results pop up in a small window on Invoices). And if not, can I just have Filemaker pop up a small window that is really dumb - that doesn't show FM's menu bar, or any of the other bells and whistles that are on the normal FM database window?
1) you've got something wrong there, obviously. The search by name shouldn't find all contacts--just those that match the selected name. In most cases, this will be a single name. Only duplicate names will require additional input from the user.
2) I've used New Window to pop up the list layout in a floating window with a script that both enters the selected record's ID and also closes the floating window. This window can be set up with the status area hidden, locked and simulating a "modal" dialog so that the user has to interact with the window or at least close it before returning to the main window.
There are also ways to use a filtered portal to list multiple matches in a list where you can click the desired portal row to add that record's ID to your current record.
Ok, I actually got it to work. However, because this search method is trying to add records to a portal - it keeps overwriting the same portal record over and over every time I search for a new part. How do I fix this?
You can use Go To Portal Row [last]
but I prefer to avoid interacting directly with a portal. Future layout changes can break such a script.
I prefer something like this:
Set variable[$ParentID ; ParentRecord::ParentId]
Go To Layout [Portal Table]
Set Field [PortalTable::ParentID ; $ParentID]
Set Field [PortalTable::PartID ; $PartID ]
Go To layout [original layout]//specify the label where you want to be when this is all done