So it sounds like your schema is:
- One to Many: Contracts to Projects
- Many to Many: Sites to Contract
On the Contract Site pivot table you'd perform looks ups to both the Contracts table and the Sites table. So the pivot could pull in Contract ID, Contract Name, Site ID and Site Name.
Then, on the Projects table you'd select a Related Contract a dropdown (via the "Many to One" from this side of the relationship).
Then, you could also have a relationship to the Contract Site Pivot (not to the Sites Table directly) where you select the Related Contract Site. In that field's properties, you'll see a "Reference field options" section where you can check a "Conditional values" box and set the match criteria where Projects: Related Contract equals Contract Site: Related Contract.
Next on the Related Contract Site Form Element Properties (not Field Props), you can specify a report that's used when conditionally selecting records. So in the Pivot table you'd create a Record Picker for Projects and use the lookups to display the Site ID And Site Name.
Then, once your conditional selection is made, you can use additional lookups on the Project to pull in "relooked up" info to display the Site Name and Site ID. For example, Projects::Contract Site - Site Name.
This is kinda tough to convey with a short forum response, but the key would be selecting records in the pivot table vs. the Site table. You may want to duplicate your current app (with it's data) or use a Builder Account to create a little playground to tinker around with these ideas and architecture.
Ideally, the relationship would be directly to Sites, but I'm not seeing that at the moment anyway … at least not without a Codepage. But, I'm still drinking my first cup of coffee :)
You would still end up with the Site ID though on the Project record (and the ability to "relook up" additional info from the Site via the pivot, which in the end it sounds like that is what you are after.
------------------------------
Brian Seymour
------------------------------