acumaticaacumatica-kb

How can I add another where condition with an OR to an existing view?


I'm adding a filter field to the Release Production Orders screen, and I want to modify the existing view that populates the grid to use this filter field. Here's the existing view:

public PXProcessingJoin<AMProdItem,
                        InnerJoin<Branch,
                            On<AMProdItem.branchID, Equal<Branch.branchID>>>,
       Where<AMProdItem.released, Equal<False>,
       And<AMProdItem.lastOperationID, IsNotNull,
       And<AMProdItem.hold, Equal<False>,
       And<Branch.baseCuryID, Equal<Current<AccessInfo.baseCuryID>>,
       And<Where<AMProdItem.function, Equal<OrderTypeFunction.regular>,
            Or<AMProdItem.function, Equal<OrderTypeFunction.disassemble>>>>>>>>> PlannedOrds;

I'd like to add the filter field to this, so my attempt looks like this:

public PXProcessingJoin<AMProdItem,
                        InnerJoin<Branch,
                            On<AMProdItem.branchID, Equal<Branch.branchID>>>,
       Where<AMProdItem.released, Equal<False>,
       And<AMProdItem.lastOperationID, IsNotNull,
       And<AMProdItem.hold, Equal<False>,
       And<Branch.baseCuryID, Equal<Current<AccessInfo.baseCuryID>>,
       And<Where<AMProdItem.function, Equal<OrderTypeFunction.regular>,
            Or<AMProdItem.function, Equal<OrderTypeFunction.disassemble>>>,
       And<Where<Current<PlannedOrdsFilter.sOOrderNbr>, IsNull,
            Or<AMProdItem.ordNbr, Equal<Current<PlannedOrdsFilter.sOOrderNbr>>>>>>>>>>> PlannedOrds;

Where THIS is the additional BQL tacked on at the end:

And<Where<Current<PlannedOrdsFilter.sOOrderNbr>, IsNull,
            Or<AMProdItem.ordNbr, Equal<Current<PlannedOrdsFilter.sOOrderNbr

This doesn't work, as I'm getting a compile error. Obviously, I'm doing something wrong, but I can't find any examples in Acumatica on how to add another AND WHERE with its own OR.


Solution

  • Ok - after much trial and error, I figured it out. The query is as follows:

       public PXProcessingJoin<AMProdItem,
                               InnerJoin<Branch,
                                   On<AMProdItem.branchID, Equal<Branch.branchID>>>,
              Where<AMProdItem.released, Equal<False>,
              And<AMProdItem.lastOperationID, IsNotNull,
              And<AMProdItem.hold, Equal<False>,
              And<Branch.baseCuryID, Equal<Current<AccessInfo.baseCuryID>>,
              And<Where2<Where<AMProdItem.function, Equal<OrderTypeFunction.regular>,
                  Or<AMProdItem.function, Equal<OrderTypeFunction.disassemble>>>,
                  And2<Where<Current<PlannedOrdsFilter.sOOrderNbr>, IsNull>,
                  Or<AMProdItem.ordNbr, Equal<Current<PlannedOrdsFilter.sOOrderNbr>>>>>>>>>>> PlannedOrds;