But you don't need a script for this, just a portal to the join table in place of the portal to the people table. Format the PeopleID field inside the portal as your drop down. You can set up one such portal to the same join table for each of the other tables, just put a different set of fields inside the portal and add a portal filter that omits records that don't have a value in the ID field for the table you have set up this particular portal to create links to it.
Thanks, Phil. That certainly works, and I may end up going with your suggestion. Ideally however, I'd like to get the scripting method to work due to some specific graphic/user interface issues. I also have many layouts that use a script so would prefer to keep things consistent. I could always split the DocumentsAssigned join table into separate tables for each relationship (there would be a total of five), but was hoping there might be another way. Performance-wise, is there a big difference between adding more tables and filtering portals via your method?
The problem is that I don't see anything for your script to do to make that happen. This all happens automatically without any scripting once you select a title from the drop down.
I leave the "Allow creation of records via this relationship" off and script the part that makes a new record in the join table and pastes in the document id. The rest (where I can click on the person id field) works normally, but it won't create a new record; the record has to already be made. Since I'm sharing this join table to use between Documents and several other tables, if I set the portal filtering as you mention I don't see the new record because there is nothing in the id_People field yet. It does work to filter the opposite way, however:
$otherIDs = Documents » DocumentsAssigned::id_ASCAPInquiries & Documents » DocumentsAssigned::id_Companies & Documents » DocumentsAssigned::id_Invoices & Documents » DocumentsAssigned::id_Projects & Documents » DocumentsAssigned::id_Songs;
$otherIDs = Null
but seems a little messy; if I add any document relationships I have to remember to change every portal filter. It seems the only ways to achieve what I'm looking for are:
1) Turn on the "Allow creation of records via this relationship" option (I prefer not to go this route)
2) Use the above filtering on each portal
3) Split out the join table into separate ones for each related table. In that case, I could use a more straightforward portal filtering (e.g. show when Documents » DocumentsAssigned::id_Documents <> Null )
I suppose there's no benefit to choosing option 2 over 3 or vice versa?
If I chose not to allow adding new portal records via the blank "add row" of a portal, but used a script button to add that record, I would use a script to create the new record in a portal with a sort order that puts the newest record at the top of the portal--having to scroll to the end of the list of portal records to add a new record is the main reason I would make such a change in the first place.
I'd then click into and select from a drop down list located inside the portal to make my selection and link this new join table record to the correct record on the "far side" of the many to many relationship.