Update a custom checkbox value(PO Screen) in a rowUpdated event handler from PORecieptEntry graph

Viewed 51

In Acumatica, I want to update UsrSendPONotifications checkbox(which is in PO screen) to true when I update a row in corresponding PO Receipt. This is the code that I tried & it is not working. So , UsrSendPONotifications checkbox remains false. Any idea about this?

protected void POReceipt_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
{
      
    var row = (POReceipt)e.Row;
    if (row == null) return;
    else
    {
        POReceiptLine receiptLine = new PXSelect<POReceiptLine, Where<POReceiptLine.receiptNbr, 
        Equal<Required<POReceiptLine.receiptNbr>>>>(Base).Select(row.ReceiptNbr);
        if(receiptLine == null) return;  
        else
        {
            POOrder poOrder = new PXSelect<POOrder, Where<POOrder.orderType, 
            Equal<Required<POOrder.orderType>>, And<POOrder.orderNbr, 
            Equal<Required<POOrder.orderNbr>>>>>(Base).Select(receiptLine.POType, 
            receiptLine.PONbr);

            if(poOrder == null) return;
            else
            {
                POOrderExt poExt = poOrder.GetExtension<POOrderExt>();
                poExt.UsrSendPONotifications = true;
                cache.SetValueExt<POOrderExt.usrSendPONotifications> 
                (poOrder,poExt.UsrSendPONotifications);
                    
             }
       }
 }
1 Answers

@AcumaticaZ Try using the existing cache for POOrder in POReceiptEntry. If you are working with regular PO this could work:

    protected void POReceipt_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
{
  
   var row = (POReceipt)e.Row;
   if (row == null) return;
   else
   {
       POReceiptLine receiptLine = new PXSelect<POReceiptLine, Where<POReceiptLine.receiptNbr, 
    Equal<Required<POReceiptLine.receiptNbr>>>>(Base).Select(row.ReceiptNbr);
       if(receiptLine == null) return;  
       else
       {
           POOrder poOrder = new PXSelect<POOrder, Where<POOrder.orderType, 
        Equal<Required<POOrder.orderType>>, And<POOrder.orderNbr, 
        Equal<Required<POOrder.orderNbr>>>>>(Base).Select(receiptLine.POType, 
        receiptLine.PONbr);

           if(poOrder == null) return;
           else
           {  poOrderUPD.Cache.SetValueExt<POOrderExt.usrSendPONotifications> 
            (poOrder,true);


            }
      }
}

      
Related