Skip to main content
Solved

Make a button that redirects to records page and applies filter

  • January 19, 2024
  • 1 reply
  • 27 views

Forum|alt.badge.img

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’’

 

 

Best answer by Zoltan Febert

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();
}

 

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

1 reply

Zoltan Febert
Jr Varsity I
Forum|alt.badge.img+3
  • Jr Varsity I
  • 176 replies
  • Answer
  • January 23, 2024

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


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