Update custom checkbox value in a rowUpdated event handler of PORecieptEntry graph
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);                      }         }       }  Â
      }
Page 1 / 1
Hi, @charithalakshan49 After creating the Purchase Receipt and Purchase Order will be in OPEN status and the system will not allows us to update the values.
As a first step, you need to enable the field from the workflow Automation steps when the PO is OPEN status and then try to update the field from the PORECEIPT.Â
Hi, @Naveen Boga Thanks for the response. Can you please tell me how to enable the field from the workflow Automation steps?
@charithalakshan49Â Can you please refer below article and let me know if you have queries.
@Naveen Boga I code like this in the POOrderEntry_Extension class in rowselected event and in workflows I uncheck the disabled checkbox from the workflows open state. But the result is same. UsrSendPONotifications checkbox still remains as false.
      Base.Document.Cache.AllowUpdate = true;       Base.Transactions.Cache.AllowUpdate = true;       Base.CurrentDocument.Cache.AllowUpdate = true;       PXUIFieldAttribute.SetEnabled<POOrderExt.usrSendPONotifications>(cache, row, true);
Â
Any idea about this? what did I do wrong?
For Header Part Use the following Code :Â
protected void POOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e) Â Â Â Â { Â Â Â Â Â Â var row = (POOrder)e.Row; Â Â Â Â Â Â Â Base.Document.Cache.AllowUpdate = true;
      PXUIFieldAttribute.SetEnabled<POOrderExt.usrSalesOrderNbr>(cache, row, true);     Â
    }
Â
For Detail Part Use the following Code :Â
Â
protected void POLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e) Â Â Â Â {
      var row = (POLine)e.Row;        POOrder order = Base.Document.Current;
      if (order == null || row == null || Base.IsExport) return;
      if (order.Status == POOrderStatus.Open ||         order.Status == POOrderStatus.Completed ||         order.Status == POOrderStatus.Closed)       {         Base.Document.Cache.AllowUpdate = true;         Base.Transactions.Cache.AllowUpdate = true;         PXUIFieldAttribute.SetEnabled<POLineExt.usrXTermStart>(cache, row, true);                  PXUIFieldAttribute.SetEnabled<POLine.dRTermEndDate>(cache, row, true);       }
    }
Â
Along with the above code you have to enable the fields in Workflow Automation step as well.
Hi @charithalakshan49Â Are you able to enable the field at screen when PO is in OPEN status?Â
Hi , @Naveen Boga yes, I enabled the field in OPEN status. But the issue is still there.
@charithalakshan49Â Â Since you are updating the field from Purchase Receipt to Purchase Order.
Please write the logic in the Persist() method in the PuchaseReceiptEntry graph extension instead RowUpdated event.
Â
  public delegate void PersistDelegate();     ÂPXOverride]     public void Persist(PersistDelegate del)     {
       //logic here
      del();
     }
@Naveen Boga Then, How do I run the logic when a row is Updated in PO Reciept screen?Â
@charithalakshan49Â Can you please let me know, what data you are updating at the PO Receipt level, so that we can decide based on this.
@Naveen Boga I update the vendor reference no. from PO Receipt screen and I want to set UsrSendNotifications checkbox to true which is in PO screen header , once I updated vendor reference from related PO receipt.
@charithalakshan49Â I have a bit of confusion in the requirement, that when you update the value in the PO Receipt Line and it needs to be updated with a flag in the PO Order level instead line?
If you have multiple lines in the PO Receipt screen, for the first line you updated the Vendor Ref, and for another line you have NOT updated. What needs to be done in the case?
Â
Â
Â
@Naveen Boga Vender ref. number is not located in the PO receipt line level. isn’t it?Â
Â
@charithalakshan49Â Yes, this is available at the header level but NOT the line level.
Please find the code sample below.Â
public class POReceiptEntryExt : PXGraphExtension<POReceiptEntry> {
public delegate void PersistDelegate(); PXOverride] public void Persist(PersistDelegate del) {
if (Base.Document.Current != null) { if (!string.IsNullOrEmpty(Base.Document.Current.InvoiceNbr)) { POOrderEntry POGraph = PXGraph.CreateInstance<POOrderEntry>();
foreach (POReceiptLine line in Base.transactions.Select()) // A PO Receipt may have multiple POs, it would be better if you get the receipt lines by grouping with POType and PONbr. { POOrder objPOOrder = PXSelect<POOrder, Where<POOrder.orderType, Equal<Required<POOrder.orderType>>, And<POOrder.orderNbr, Equal<Required<POOrder.orderNbr>>>>>.Select(Base, line.POType, line.PONbr); if (objPOOrder != null) { POGraph.Document.Current = objPOOrder; POOrderExt poExt = objPOOrder.GetExtension<POOrderExt>(); poExt.UsrSendPONotifications = true; POGraph.Document.Cache.Update(objPOOrder); POGraph.Save.Press(); } } } }
del(); } }
public class POOrderExt : PXCacheExtension<POOrder> { PXDBBool] PXUIField(DisplayName = "Send Notification")] public bool? UsrSendPONotifications { get; set; } public abstract class usrSendPONotifications : PX.Data.BQL.BqlBool.Field<usrSendPONotifications> { } }
Â
@Naveen Boga Thank you so much for being helpful. It worked!
@charithalakshan49Â Â Most welcome Thanks for sharing the update.