I'm working on an inquiry screen that's mostly a copy of the Inventory Summary screen (IN401000), but I'm trying to open it up across branches. The existing screen does its search within a private method of the graph that contains a lot of code that builds up the results in buckets and aggregates, concatenates, and totals it. I subclassed that graph, and overrode the protected level to wrap it in a PXReadBranchRestrictedScope, but it's not returning data from multiple branches. The results are returned in a special Result IBqlTable class that is filled manually and doesn't have a BranchID defined, so I created a cache extension that adds it, and I fill it manually. So right now, I'm guessing that either the private method is ignoring the PXReadBranchRestrictedScope, or it doesn't work when BranchID is on an extension of the result class. Below are the skeletons of my classes. Any suggestions on getting it to work?
public class ItemAvailByBranchInq : PX.Objects.IN.InventorySummaryEnq
{
protected override IEnumerable<InventorySummaryEnquiryResult> iSERecordsFetch()
{
using (new PXReadBranchRestrictedScope(null, branches,
restrictByAccessRights : false))
{
foreach (InventorySummaryEnquiryResult rec in base.iSERecordsFetch())
{
yield return new PXResult<InventorySummaryEnquiryResult>(rec);
}
}
}
}
[PXNonInstantiatedExtension]
public class InventorySummaryEnquiryResultExt :
PXCacheExtension<InventorySummaryEnquiryResult>
{
public abstract class branchID : BqlType<IBqlInt, int>.Field<branchID> { }
[Branch(null, typeof(Search<Branch.branchID>), Required = false,
IsEnabledWhenOneBranchIsAccessible = true, IsDetail = false)]
public int? BranchID { get; set; }
}
I pulled out the SQL being executed, and for the INSite-related queries involved, it is only looking at rows for the current branch instead of all branches (which I pass into PXReadBranchRestrictedScope as a list above).