JB90
JB90

Reputation: 95

Filtering PXselector with search

I have a custom grid using a custom dac that I have declared. Originally i had a PXselector attribute set to POOrder.orderNbr

With this selector it grabs all POOrders in my grid selector

 [PXDBString(50, IsKey = true, IsUnicode = true, InputMask = "")]
    [PXSelector(typeof(POOrder.orderNbr))]
    [PXUIField(DisplayName = "Po#")]
    public string Po { get; set; }

    public class po : IBqlField { }

enter image description here

But i want the selector to filter POOrders that appear on the Document details->POReceiptLine. I attempted to filter using the Search but only get the lowest value POOrder.ordnbr on the receipt. The images below should illustrate what I mean. I want it to show all POOrder.orderNbr but it's only retrieving the first lowest value order.

[PXDBString(50, IsKey = true, IsUnicode = true, InputMask = "")] [PXSelector(typeof(Search<POOrder.orderNbr,Where<POOrder.orderNbr,Equal<Current2<POReceiptLine.pONbr>>>>))] [PXUIField(DisplayName = "Po#")] public string Po { get; set; } public class po : IBqlField { }

Document Details

Grid with only lowest order

Upvotes: 0

Views: 2103

Answers (2)

Philippe
Philippe

Reputation: 986

The main issue in the selector is that you are looking for POOrder where the order Number equals the current Receipt Line. That means that depending the line selected, the value will change but will always yield only one result. The solution would then be to change the condition to be on the Purchase Receipt document instead.

To do so you have two options. Either you search directly POReceiptLine.poNbr, but then your selector will display columns from that table, or you join POOrder to POReceiptLine.

  1. With search on POReceiptLine
[PXSelector(typeof(Search<POReceiptLine.pONbr,
    Where<POReceiptLine.receiptType,
        Equal<Optional<POReceipt.receiptType>>,
    And<POReceiptLine.receiptNbr,
        Equal<Optional<POReceipt.receiptNbr>>>>>), DirtyRead = true)]
  1. With search on POOrder
[PXSelector(typeof(Search2<POOrder.orderNbr,
        InnerJoin<POReceiptLine, On<POReceiptLine.pOType,
            Equal<POOrder.orderType>,
        And<POReceiptLine.pONbr,
            Equal<POOrder.orderNbr>>>>,
        Where<POReceiptLine.receiptType,
            Equal<Optional<POReceipt.receiptType>>,
        And<POReceiptLine.receiptNbr,
            Equal<Optional<POReceipt.receiptNbr>>>>>))]

Also notice the parameter DirtyRead = true. This parameter will tell the selector to get it's information in the cache and not only from the Database. Because you are selecting something from the same page, you would need to save the whole document before being able to select the record otherwise. Unfortunatly it would not work with the second option because the Join is done at the database level.

Upvotes: 2

RuslanDev
RuslanDev

Reputation: 6778

I believe it would be much better if you inner join POReceiptLine DAC, and then aggregate associated Purchase Orders to eliminate possible duplicates:

[PXSelector(typeof(Search5<POOrder.orderNbr, 
    InnerJoin<POReceiptLine, On<POReceiptLine.pOType, Equal<POOrder.orderType>,
        And<POReceiptLine.pONbr, Equal<POOrder.orderNbr>,
        And<POReceiptLine.receiptNbr, Equal<Current<POReceipt.receiptNbr>>>>>>,
    Aggregate<GroupBy<POOrder.orderType,
        GroupBy<POOrder.orderNbr>>>>))]

Upvotes: 4

Related Questions