Solved

Sum values of detail rows (in extension) and put it in header (in extension)

  • 27 September 2021
  • 2 replies
  • 902 views

Userlevel 2
Badge

I am using PXFormula to multiply a qty and cost to create a new extension field in the details of Physical Inventory Review (although I would think the specific screen wouldn’t matter.) That part is working fine. However, I then want to sum that new column’s values into a new extension field in the header. I can't get that part to work.

Here is the relevant detail code:

using PX.Data;
using System;

namespace PX.Objects.IN
{
  public class INPIDetailExt : PXCacheExtension<PX.Objects.IN.INPIDetail>
  {
        #region UsrExtBookCost
        [PXDecimal]
        [PXUIField(DisplayName="Ext. Book Cost")]

        [PXFormula(typeof(Mult<INPIDetail.bookQty, INPIDetail.unitCost>),
        typeof(SumCalc<INPIHeaderExt.usrTotalBookCost>))]
        public virtual Decimal? UsrExtBookCost { get; set; }
        public abstract class usrExtBookCost : PX.Data.BQL.BqlDecimal.Field<usrExtBookCost> { }
        #endregion
  }
}

 

Here’s the header code:

using PX.Data;
using System;

namespace PX.Objects.IN
{
  public class INPIHeaderExt : PXCacheExtension<PX.Objects.IN.INPIHeader>
  {

    #region UsrTotalBookCost

    [PXDecimal]
    [PXUIField(DisplayName="Total Book Cost")]

    public virtual Decimal? UsrTotalBookCost { get; set; }
    public abstract class usrTotalBookCost : PX.Data.BQL.BqlDecimal.Field<usrTotalBookCost> { }
    #endregion
  }
}

 

 

I feel it has something to do with the fact that these are extensions and that somehow the PXParent that is called in INPIDetail does not cover these extension.

icon

Best answer by Naveen Boga 27 September 2021, 21:07

View original

2 replies

Userlevel 7
Badge +17

Hi @davidrichards12   In the past I also faced the same issue. 

 

Below comment is from Acumatica support Team on the other site.

It is a known issue that SumCalc does not work as expected in PXParent DACs.

I can only recommend using graph event handlers RowSelectedor FieldSelectingto calculate the sum instead of a solution that includes DAC attributes. You can add a comment explaining the limitation of DAC attributes in the event handler if you require Acumatica ISV certification for your solution.

Userlevel 2
Badge

Thank you Naveen. I did find in Acumatica’s own code (in INPIDetail.cs) that they specifically did not use PXFormula to sum Physical Qty. There is actually a comment in their code admitting the issue.

 

But thank you for directing me to the right events to use. I appreciate the quick response.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved