Skip to main content
Answer

Code performance optimizing, move event in SOline_rowselected to?

  • March 29, 2022
  • 4 replies
  • 83 views

Forum|alt.badge.img+6

Hello,

     We are having some legacy codes like below (with some modifications to make it look short):

 protected void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{

SOLine soLine = (SOLine)e.Row;
if (soLine != null)
{

PXUIFieldAttribute.SetEnabled<SOLineExt.usrEstWgt>(cache, soLine, false);

InventoryItem item = PXSelect<InventoryItem,
Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>
.Select(Base, soLine.InventoryID);
if (item != null)
{
InventoryItemExt rowExt = PXCache<InventoryItem>.GetExtension<InventoryItemExt>(item);
SOLineExt soLineExt = PXCache<SOLine>.GetExtension<SOLineExt>(soLine);
cache.SetValue<SOLineExt.usrBrand>(soLine, rowExt.UsrBrand);
cache.SetValue<SOLineExt.usrPackSize>(soLine, rowExt.UsrPackSize);
}

}
}

 

            It is not perfect, but can run without error.

However, recently, after upgrading to 2021R2, user are complaining the SO entry becomes slow with more than 10 lines on.

 

            It probably  Caused by the soline_rowselected event. But if I would like to rewrite. What is the best event place I move the codes to?

Best answer by Naveen Boga

Hi @ray20  Yes, we can disable the field without code as well.


We can achieve this from the Automation steps in the customization package. Please find the screenshot for disabling the field.

 

4 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • March 29, 2022

Hi @ray20  Yes, we should not assign the values in the Row selected event, it will slow down the performance.

 

You can remove the code from the Rowselected event except enable code and move it to InventoryID_FieldUpdated event.

Let me know code if any code samples required.


Forum|alt.badge.img+6
  • Author
  • Captain II
  • March 29, 2022

@Naveen Boga Thank you ,code master.
Do we know whether it is possible to disable the soline extension fields without writing codes?

If I remain the enable and disable codes in rowselected, would it still effect on the performance?​​​​​


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • March 29, 2022

Hi @ray20  Yes, we can disable the field without code as well.


We can achieve this from the Automation steps in the customization package. Please find the screenshot for disabling the field.

 


Forum|alt.badge.img+6
  • Author
  • Captain II
  • March 29, 2022

@Naveen Boga  Thank you ,code master.
I will have a try later.