Skip to main content

Hi,

I need to add new field name as ‘Claim Percentage’ into sales order invoice screen. And when the claim Percentage is entered Invoice Amount need to be calculated like below formula.

amount = unit price * qty * (claim Percentage/100)

I have add fieldUpdated event into SOInvoiceEntry screen.

 protected void ARTran_UsrClaimPercentage_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{

var row = (ARTran)e.Row;
ARTranExt detail = PXCache<ARTran>.GetExtension<ARTranExt>(row);
decimal? val1 =detail.UsrClaimPercentage/100;
decimal? val = row.CuryTranAmt*val1;
row.CuryTranAmt = val;
// cache.SetValueExt<ARTran.curyTranAmt>(row, val);

}

When adding the claim Percentage at 1st time formula is working properly.But, after that when changing the same field Amount calculation is wrong.

  • 1st change
  • 2nd change for same row same field.Amount need to 25

  •  

Why This is happened?

 

@jeewanishalika20  CuryTranAmt is a calculated field that relies on the Ext Price field and various Discount-related fields at the line level.

When your custom logic attempts to modify the value upon updating the custom field UsrClaimPercentage, subsequent events are triggered, resulting in updates to the Amount field.


Reply