Skip to main content
Answer

Field updated event not working as expected

  • June 7, 2023
  • 1 reply
  • 160 views

Forum|alt.badge.img

Hi all,

I have a field updated event for soorder invoices screen Artran qty field which is used to get line weight by multiplying item weight and qty as below.

public PXSelect<InventoryItem> dataview; 

protected void ARTran_Qty_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{

var row = (ARTran)e.Row;
ARTranExt detail = PXCache<ARTran>.GetExtension<ARTranExt>(row);
foreach (PXResult<InventoryItem> result in dataview.Select()){

InventoryItem item = result;
if(item.InventoryID == row.InventoryID) {

detail.UsrItemWeight = item.BaseItemWeight;


decimal? LineWeight = row.Qty * detail.UsrItemWeight;
detail.UsrLineWeight = LineWeight;
}


}

}

usrLineweight is the custom field for Line Weight in details level of invoices screen. The line weight should be calculated just after qty field is updated. But it’s only working in the time when adding a new row. How can I solve this issue?

Thank you.

Best answer by sweta68

Hi @oshadarodrigo64 

Could you please replace

detail.UsrLineWeight = LineWeight;

line with 

cache.SetValueExt<ARTranExt.usrLineWeight>(row, LineWeight);

instead of setting the detail.UsrLineWeight field directly, use the cache.SetValueExt method to update the field value.

Hope, It works!

Regards,

Sweta

1 reply

Forum|alt.badge.img+9
  • Semi-Pro III
  • Answer
  • June 7, 2023

Hi @oshadarodrigo64 

Could you please replace

detail.UsrLineWeight = LineWeight;

line with 

cache.SetValueExt<ARTranExt.usrLineWeight>(row, LineWeight);

instead of setting the detail.UsrLineWeight field directly, use the cache.SetValueExt method to update the field value.

Hope, It works!

Regards,

Sweta