Skip to main content
Solved

Field updated event not working as expected

  • June 7, 2023
  • 1 reply
  • 138 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

View original
Did this topic help you find an answer to your question?

1 reply

Forum|alt.badge.img+9
  • Semi-Pro III
  • 229 replies
  • 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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings