Skip to main content
Solved

Cross-branch inventory summary with PXReadBranchRestrictedScope

  • February 2, 2025
  • 2 replies
  • 20 views

Tony Lanzer
Semi-Pro I
Forum|alt.badge.img+1

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).

Best answer by Tony Lanzer

This ended up being a coder error and it does work after all.  The branches parameter I was passing into the PXReadBranchRestrictedScope was actually getting set to a single branch, thus the SQL and results were only of that branch.  Once I fixed the code leading up to it set the parameter to a branch list (or null for all) properly, it started working.

View original
Did this topic help you find an answer to your question?

2 replies

Tony Lanzer
Semi-Pro I
Forum|alt.badge.img+1
  • Author
  • Semi-Pro I
  • 75 replies
  • Answer
  • February 3, 2025

This ended up being a coder error and it does work after all.  The branches parameter I was passing into the PXReadBranchRestrictedScope was actually getting set to a single branch, thus the SQL and results were only of that branch.  Once I fixed the code leading up to it set the parameter to a branch list (or null for all) properly, it started working.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2761 replies
  • February 4, 2025

Thank you for sharing your solution with the community ​@Tony Lanzer!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings