I am trying to customize a Branch lookup in Acumatica so that it only shows branches belonging to the currently logged-in user's organization.
When a user opens the Branch selector, it should display only branches that belong to the same organization as the current branch.
The following SQL query returns the correct result:
SELECT *
FROM Branch
INNER JOIN Branch AS Br
ON Br.OrganizationID = Branch.OrganizationID
WHERE Br.BranchID = 22;Here, 22 represents the current logged-in branch (AccessInfo.BranchID in Acumatica).
I tried to convert the same logic into BQL, but the result returns duplicate records instead of the expected filtered list.

Below are some of the approaches I tried: I also tried several other variations by making small changes, such as modifying the join type and other conditions, but I still ended up with the same result.
Following is the BranchAliespublic class BranchAlias : PX.Objects.GL.Branch { }
[PXSelector(typeof(Search2<
Branch.branchID,
InnerJoin<BranchAlias,
On<BranchAlias.organizationID, Equal<Branch.organizationID>, And<BranchAlias.branchID, Equal<Current<AccessInfo.branchID>>>>>
>),
SubstituteKey = typeof(Branch.branchCD),
DescriptionField = typeof(Branch.acctName)
)]
[PXSelector(typeof(Search2<
Branch.branchID,
LeftJoin<
BranchAlias,
On<
BranchAlias.organizationID,
Equal<Branch.organizationID>
>
>,
Where
<BranchAlias.branchID,
Equal<Current<AccessInfo.branchID>>>
>),
SubstituteKey = typeof(Branch.branchCD),
DescriptionField = typeof(Branch.acctName)
)]