Skip to main content
Answer

value can not be null parameter name key

  • April 30, 2023
  • 2 replies
  • 854 views

Forum|alt.badge.img

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.

Best answer by Naveen Boga

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";
}
}
}
}

 

2 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • May 1, 2023

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";
}
}
}
}

 


Forum|alt.badge.img

Hi @naveen,

 

Thanks it’s working.

Regards