How to inject delegate for PXFilteredProcessingJoin and similar classes


want to share code, which was written in the context of this question on Question is how to modify request and use filtering with help of In or IsIn operator of Acumatica framework. 

After plenty of trial and error, here is the code, with which I've come:

public class INReplenishmentFilterExt : PXCacheExtension<PX.Objects.IN.INReplenishmentFilter>
    #region UsrWarehouse
    [PXSelector(typeof(INSite.siteCD), typeof(INSite.siteCD), typeof(INSite.descr), ValidateValue = false, DescriptionField = typeof(INSite.siteCD))]
    [PXUIField(DisplayName = "Warehouse")]
    public virtual string UsrWarehouse { get; set; }
    public abstract class usrWarehouse : PX.Data.BQL.BqlString.Field<usrWarehouse> { }
public class INReplenishmentCreate_Extension : PXGraphExtension<PX.Objects.IN.INReplenishmentCreate>
    public override void Initialize()
        BqlCommand cmd =
            new SelectFrom<INReplenishmentItem>();
        var f1 = new PXSelectDelegate(
            () =>
                return records1(Base);
        Base.Views["Records"] = new PXView(Base, false, cmd, f1);
    public virtual IEnumerable records1(PXGraph graph)
        var cr = Base.Filter.Current;
        if (cr != null)
            var ext = cr.GetExtension<INReplenishmentFilterExt>();
            var objs = ext.UsrWarehouse.Split(';').ToList().Select(a => a.Trim()).ToArray<String>();
            var listResults = new List<INReplenishmentItem>();
            var warehouses = SelectFrom<INSite>.Where<INSite.siteCD.IsIn<@P.AsString>>.View.Select(graph, new[]{ objs}).ToList(100);
            var wsIds = warehouses.Select(a => a.GetItem<INSite>().SiteID).ToList();
            return SelectFrom<INReplenishmentItem>.Where<INReplenishmentItem.siteID.IsIn<@P.AsInt>>.View.Select(graph, wsIds.ToArray());
            return Base.Records.Select(Base);

Want to highlight usage of PXSelectDelegate. With it's usage, you can inject any kind of business logic into your graph extension.



 As Gabriel Michaud once pointed, with great power comes great responsibility. Use this code with carefullness, as you may introduce bugs, especially if couple more packages are running along with yours.