0
votes

I've got a customization to the Sales Order Form (SO301000) that's acting really whacky. The goal is to use 5 custom fields to calculate the added charge on a line. I've got the 5 fields working (1 int, 4 decimal 8,3), added the code and attirbutes to make them update the line after edit. After each of the fields updates I run a line update function, at the end of which it updates the Quantity, Discount amount and a custom field (which is for troubleshooting).

What's making me crazy is that it updates the quantity and custom field perfectly...but on the 4 decimal fields it seems it updates the discount only every other time. At first I thought I was running into some logic, the the int field (and I have no idea if it's related to the variable type, but that's the only difference I can see) works every single time

The code to update after each field change is all the same (other, of course, than the field name):

protected void SOLine_UsrWidthAdder_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
    UpdateLineDirect(cache, (SOLine)e.Row);
}

And the code at the end of UpdateLineDirect looks like this:

cache.SetValue<SOLine.manualDisc>(TheRow, true);
cache.SetValue<SOLine.discPct>(TheRow, dDiscountPercent); 
cache.SetValue<SOLineExt.usrCostCalc>(TheRow, TestString);
cache.SetValue<SOLine.curyDiscAmt>(TheRow, dDiscountAmount); 
cache.SetValueExt<SOLine.orderQty>(TheRow, dQO);  

I've tried a variety of orders of updating fields, and updating them all with Ext to force a calculation each time, but none of the combos I have tried seem to make much difference.

Thanks in advance!

1
To execute the events correctly have you tried using SetValueExt on all fields? You might need to look at the formulas that are running and might need to set manual price field to make sure some pricing logic doesn't also override your value. - Brendan
I think I've got it working now. After a little playing I used Ext on the curyDiscAmt and removed setting the discPct. I think it didn't like me trying to set them both in one update and it got real confused. Thanks for your assistance. - T-Rav

1 Answers

0
votes

So, looks like Acumatica doesn't like to have the discount amount and percent updated at the same time.

I removed this line:

cache.SetValue<SOLine.discPct>(TheRow, dDiscountPercent); 

and only update this one (which is what I wanted in the first place)

cache.SetValue<SOLine.curyDiscAmt>(TheRow, dDiscountAmount); 

and it now works perfectly.