I have a couple of complicated queries that are having my pull my hair our.
I have a number of different Contact Types instantiated as BOs.
Contact1000, Contact1001, Contact2000 and Contact2001
These BOs are grouped into ContactGroupContracting.
ContactGroupContracting has a common attribute psRole which identifies what sub-type of Contact it is (for many reasons that Type() wouldn't be sufficient for)
Contact1000 and Contact1001 has an additional psProprietor which can be UNDEFINED.
I'm trying to find all of the ContactGroupContracting where the Contact1001.psProprietor is UNDEFINED.
I've tried this:
FIND ContactGroupContracting WHERE ContactGroupContracting.obTenant=LoggedInRegularUser.obTenant AND ContactGroupContracting.psRoleSub.obRole.Code=1000 AND (ContactGroupContracting.psRoleSub.Code=1200 OR EXISTS Contact1001 WHERE (ContactGroupContracting.ID=Contact1001.ID AND Contact1001.psRelatedProprietor IS UNDEFINED))
(I've tried ContactGroupContracting.ID=Contact1001.ID and Contact1001.ID=ContactGroupContracting.ID)
But this is bringing back all of the Contact1000/1 and ignoring the psRelatedProprietor IS UNDEFINED
Any suggestions as to where I am going wrong?
=============== How I fixed this ===================
My solution was a bit of work around rather than a solution.
I have used an interim BO and set different fields dependent on the starting point (ie was it a Seller Contact or a Buyer Contact). I've then loaded up a different form depending on which fields are initially set and have 'locked' these fields using shortcuts to the Name attribute on the record. If I start from a Buyer Contact then I populate the Buyer Contact attribute and then show a form with a shortcut to Buyer.Name. This alleviates the need for a complex query.