Hi :) What I'm trying to achieve is creating a Contact selector that, when you click on the selector icon, it brings up a filtered result of the contacts table that only shows Contacts related to that specific company, as shown below:
The above image is in the Sales Orders screen, and I'm aiming to actually have it in the Projects screen. So when I tried moving it over, making sure to have the same setup, it doesn't seem to be working in the Projects screen.
When I try opening the selector, the box is empty. I thought that maybe the problem was that the values I was trying to match between the PMProject table and the BAccount table weren't matching, so I used the Description field to output the values I was getting, and they appear to be the same.
This is the setup I am using to create the selector:
[PXUIField(DisplayName="Contact")]
[PXSelector(typeof(Search2<Contact.displayName,
LeftJoin<BAccount, On<BAccount.bAccountID, Equal<Contact.bAccountID>>>,
Where<Contact.contactType, Equal<ContactTypesAttribute.person>>>))]
[PXRestrictor(typeof(
Where<Current<PMContact.customerID>,
Like<BAccount.bAccountID>>), "")]
It's exactly the same setup that I was using for the Sales Order screen, just obviously now it's using the CustomerID of PMProject instead.
Is there something I am doing incorrectly? Any help would be appreciated :D
UPDATE
Thanks for the answer Joseph! The contact field still shows up as being empty when I click into it. See below:
This is how I added the solution:
I managed to solve this issue. Joseph's answer made me rethink how I was matching contacts with the current project, as instead of using the BAccount table, I could use the Contact table instead.
I found that I just needed to compare the Contact.bAccountID field with the value of the PMContact.customerID field, and that would give me all the associated contacts.
Adding this comparison to the PXRestrictor solved this issue for me :)
[PXDBString(50)]
[PXUIField(DisplayName="Contact")]
[PXSelector(typeof(Search2<Contact.displayName,
LeftJoin<BAccount, On<BAccount.bAccountID, Equal<Contact.bAccountID>>>,
Where<Contact.contactType, Equal<ContactTypesAttribute.person>>>))]
[PXRestrictor(typeof(
Where<Current<PMContact.customerID>,
Like<Contact.bAccountID>>), "")]