Skip to main content
Solved

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

  • September 27, 2021
  • 2 replies
  • 1143 views

davidrichards12
Freshman II
Forum|alt.badge.img

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.

Best answer by Naveen Boga

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.

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

2 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • Answer
  • September 27, 2021

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.


davidrichards12
Freshman II
Forum|alt.badge.img

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


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