Skip to main content

Hi,

I create a new data field into my purchase order screen poline DAC,

>PXDBString(10)]
>PXUIField(DisplayName="uomnew")]

Then I try to set field value in rowselected event.

 public class POOrderEntry_Extension : PXGraphExtension<PX.Objects.PO.POOrderEntry>
  {
    #region Event Handlers

    protected void POLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
    {
      
      var row = (POLine)e.Row;
      POLineExt poLine = PXCache<POLine>.
           GetExtension<POLineExt>(row);
      poLine.Usruomnew= "news";
     if(poLine != null){
       poLine.Usruomnew= "new";
     }
      
    }

    

    #endregion
  }

 

After adding POOrderEntry_Extension and published It shows an error below like that.

Can you please give solution for that.

Hi @jeewanishalika20  It is NOT recommended to assign the value in the Row_Selected event.

Please move it a proper event.

In the above code, there are no NULL checks hence you're getting this issue. I have modified your code and below is the working code.

 

    public class POOrderEntry_Extension : PXGraphExtension<PX.Objects.PO.POOrderEntry>
{
protected void POLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
var row = (POLine)e.Row;
if (row != null)
{
POLineExt rowExt = row.GetExtension<POLineExt>();
if (rowExt != null)
{
rowExt.Usruomnew = "news";
}
}
}
}

 


Hi @naveen,

 

Thanks it’s working.

Regards


Reply