Skip to main content
Solved

Sales Order Ordered Qty is out of sync to line Quantity

  • January 2, 2024
  • 5 replies
  • 230 views
  • Translate All

Forum|alt.badge.img

In Sales Order Entry, the header SOOrder.OrderQty is SumCalc by the SOLine.OrderQty. I changed the SOLine.OrderQty in the SOLine_RowUpdated event by:

      cache.SetValueExt<SOLine.orderQty>(row, newValue);

 

The line quantity did change to the new value, but the header SOOrder.OrderQty still keep the old value. I added another statement:

     PXUnboundFormulaAttribute.CalcAggregate<SOLine.orderQty>(cache, row);

But still no change. Am I missing something?

 

Thanks,

Best answer by junmao01

I moved my function to FieldUpdated event and it worked. 

View original

5 replies

Naveen Boga
Captain II
Forum|alt.badge.img+20

@junmao01 I may be missing something here.

By default, Acumatica will do the SUM calculation of SOLine Order Qty and update it in the header level Order Qty field. 

Can you please let me know why are you updating the QTY in the RowUpdated event. 

Translate

Forum|alt.badge.img
  • Author
  • Varsity I
  • January 3, 2024

@Naveen Boga Thanks for the response. This is for return order from Website through API. For example, customer ordered 5 items, Acumatica only shipped 3. The Website created a return order through API. In Acumatica I check the return quantity, if it exceeds the shipped quantity, I set it to shipped quantity. So in RowUpdated event, it customer return quantity 5, but we only shipped 3, then I set the quantity to 3.

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20

Understood @junmao01  Thanks for sharing the details.

Seems like caches are not updating properly from the code. Can you please share the source code, so that we can check from our end and let you know.

Translate

Forum|alt.badge.img
  • Author
  • Varsity I
  • January 3, 2024

@Naveen Boga It seems the RowUpdated event get called several times. I have a condition to set the Order quantity:

// Get allowed return quantity allowedReturnQty

…...

decimal? ordQty = row.OrderQty;

if (ordQty > allowedReturnQty)

{

    ordQty = allowedReturnQty;

    cache.SetValueExt<SOLine.orderQty>(row, ordQty);

}

 

The SetValueExt only get called once. It changed the line OrderQty, but it seems doesn’t trigger the SumCalc. If I remove the condition and let the SetValueExt get called every time the RowUpdated is called, then it works. I wonder when the SumCalc is triggered.

Translate

Forum|alt.badge.img
  • Author
  • Varsity I
  • Answer
  • January 8, 2024

I moved my function to FieldUpdated event and it worked. 

Translate