I am generating a document off of the Opportunity object. It needs to return a table of Contact names where the Contact's role is "Main Contact."
I can get it to return that table, the problem is that it is also returning "Main Contact"s from any account related to the opportunity via a custom lookup field we have.
To try to make a little more sense of what's going on, our clients can potentially come to us through brokers or partnerships, and the opportunity has a custom lookup field that looks up the broker/partner so we have it on record. The table I'm getting back from my setup is returning all Main Contacts, even the ones from the company attached via the Broker/Partner field, regardless of whether or not that contact has been linked to the company I'm trying to generate a document for.
It is entirely possible that a Main Contact for a given company might be from a broker and thus have a different Company Name related to them, so I can't filter by whether or not the contact is a broker or not.
Does anyone have any idea why this is happening and how I can get it to stop? I've attached screenshots of the relationship set-up I have as well as the field tag in the document proper.