0
votes

I need to add a filter to the Process Orders screen grid, so that only orders that have an unpaid balance = 0 will show, based on an additional checkbox to the filter area called 'Must Have Payment' being checked. I thought I had it by adding a where clause to the Orders view, but that didn't work.

    [PXFilterable]
    public PXFilteredProcessing<SOOrder, SOOrderFilter,
                                Where<SOOrder.unpaidBalance, NotEqual<Zero>,
                                Or<Current<SOOrderFilterExt.mustHavePayment>, Equal<False>>>> Orders;

I'm sure I'm doing this incorrectly, as all orders are showing and not just the 'Open' orders as it was before I added this change. I'd like to override the view delegate and modify that to add my filter / condition to the returned rows, but I can't override this method - at least that I can tell.

What's the best way to get this custom filter restriction into the select for that grid?

Thanks much...

1

1 Answers

0
votes

Overriding the dataview delegate may not be the best idea on this specific case.

I noticed that AddCommonFilters() method is not private (used in the dataview delegate), so I think you could try to override this method instead, call Base method and then inject your custom code to include your query filter into the main query used on the for each.

Maybe this is something you can use to implement your filtering, see snippet below:

public class SOCreateShipment_Extension : PXGraphExtension<SOCreateShipment>
{
    #region Event Handlers
    public delegate void AddCommonFiltersDelegate(SOOrderFilter filter, 
       PXSelectBase<SOOrder> cmd);
    [PXOverride]
    public void AddCommonFilters(SOOrderFilter filter, PXSelectBase<SOOrder> cmd, AddCommonFiltersDelegate baseMethod)
    {
        baseMethod(filter,cmd);
        //Add your custom code here

        if (Yourcondition)
        {
           cmd.WhereAnd<Where<YOURFILTERINGCondition>>>>();
        } 
     }
........................

Please also review the AlterFilters() method if needed.