Skip to main content

I made a button in actions that goes from the customers to ‘Customers Last Trans’. I want to add the logic for the button to make it so when I click it from customer ‘c000032’ it will go to the customer last trans page which contains records of the last transactions and then apply the filter ‘equal to c000032’ so only that customers records come back. here;s my custon  LastTransFilter graph  ‘namespace TestProject
{
    tSerializable]
    public class LastTransFilter : IBqlTable
    {
        #region CustomerID
        public abstract class customerID : PX.Data.BQL.BqlInt.Field<customerID> { }

        iPXInt]
        ;PXUIField(DisplayName = "Customer")]
        ÂPXSelector(typeof(Search<Customer.bAccountID>),
            typeof(Customer.acctCD),
            typeof(Customer.acctName),
            SubstituteKey = typeof(Customer.acctCD))]
        public virtual int? CustomerID { get; set; }
        #endregion
    }
}’

 

here’s my CustomerMaint Graph extension ‘    protected IEnumerable records(PXAdapter adapter)
{
    Customer customer = Base.BAccount.Current;
    if (customer != null)
    {
        CustomerLastTrans graph = PXGraph.CreateInstance<CustomerLastTrans>();
        LastTransFilter filter = graph.Filter.Current;
        filter.CustomerID = customer.BAccountID;

        throw new PXRedirectRequiredException(graph, "Customer Last Transaction")
        {
            Mode = PXBaseRedirectException.WindowMode.NewWindow
        };
    }
    return adapter.Get();
}

    #endregion
}

final custom graph ‘namespace TestProject
{
    public class CustomerLastTrans : PXGraph<CustomerLastTrans>
    {
        public PXFilter<LastTransFilter> Filter;
        public PXSelect<ARInvoice,
        Where<ARInvoice.customerID, Equal<Current<LastTransFilter.customerID>>>> LastTransaction;

        public CustomerLastTrans()
        {
            LastTransaction.Cache.AllowInsert = false;
            LastTransaction.Cache.AllowDelete = false;
        }
    }
}

 

 

the button redirects but does not apply the filter’’

 

 

Hi @philipkantewa56,

You updated the filter, but you forgot to update the filter view. Please find my comments in code sample below.

protected IEnumerable records(PXAdapter adapter)
{
Customer customer = Base.BAccount.Current;
if (customer != null)
{
CustomerLastTrans graph = PXGraph.CreateInstance<CustomerLastTrans>();
LastTransFilter filter = graph.Filter.Current;
filter.CustomerID = customer.BAccountID;

// Add this
graph.Filter.Update(filter);
// You might need this as well
graph.Filter.Current = filter;

throw new PXRedirectRequiredException(graph, "Customer Last Transaction")
{
Mode = PXBaseRedirectException.WindowMode.NewWindow
};
}
return adapter.Get();
}

 


Reply