Solved

Make a button that redirects to records page and applies filter

  • 19 January 2024
  • 1 reply
  • 23 views

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
{
    [Serializable]
    public class LastTransFilter : IBqlTable
    {
        #region CustomerID
        public abstract class customerID : PX.Data.BQL.BqlInt.Field<customerID> { }

        [PXInt]
        [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’’

 

 

icon

Best answer by Zoltan Febert 23 January 2024, 01:51

View original

1 reply

Userlevel 6
Badge +3

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


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved