x++dynamics-ax-2012-r3

Sum of real value field ,the value to change dynamically as I navigate through lines in Grid. in AX 2012 r3


Placing the calculation logic in the lines table causes the value to change dynamically as you navigate through lines. It in the header table seems to provide a static value, but it's unclear why.

 Public real getTotalConsumptionCost(ProdId _prodId)
{
    ProdJournalBOM prodJournlBOM;
    real totalCost = 0;


    select sum(ConsCost) from prodJournlBOM
           where prodJournlBOM.ProdId == _prodId;

    totalCost = prodJournlBOM.ConsCost;

    return totalCost;
} 


Select data from the header table to update and insert new records in the lines table. So where to write a method in a table of headers or lines.
  1. By placing the calculation logic in the ProdTable, I ensure that the total consumption cost is calculated consistently for any given product.

  2. The getCalculatedTotalCost method in the ProdJournalBOM table provides a convenient way to access the calculated value for each line.


Solution

  • How about

    public display real getTotalConsumptionCost()
    {
        ProdId _prodId = this.ProdId;
    ...