0
votes

i some problems about calculate unbound field, i want get value from grid by row index like RowIndex property in c#, is it available from acumatica?

protected virtual void BSMTActivityTypePlanDetail_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        if(e.Row == null)
        {
            return;
        }

        BSMTActivityTypePlan head = new BSMTActivityTypePlan();
        BSMTActivityTypePlanDetail detail = (BSMTActivityTypePlanDetail)e.Row;

        for (int x = 0; x <= DetailActTypePlans.Select().RowCount; x++)
        {
            head.TotalPlanAct += DetailActTypePlans.
        }


    }

What could be the correct way to solve this problem? thanks

2
It is unclear what you are trying to ask? Could you rephrase your question? - bit
Hmmm, since the RowSelected event always runs after the event chain execution, for example: RowUpdated -> ... (I can't remember exactly what run after RowUpdated) -> RowSelected, FieldUpdated -> ..... -> RowSelected so it could be heavy load or wrong calculation when you put in the RowSelected event. If your unbound field is only calculated at the first time the row is loaded then I suggest using the RowSelecting to do this calculation - HDanh
@HDanh : thanks for your suggest, can i get value with row index property ? - Distor4by
Not sure what your end goal is but if you are looking to add child data up to a parent record or calculate an unbound field then you should look into PXFormula or PXUnboundFormula. Source the Acumatica source for examples of its use. - Brendan
Formula attribute should also work. - Sin

2 Answers

3
votes

I see 2 possible ways of arriving at a possible solution:

The first one is closer to what you would have liked to achieve: to use “foreach” instead of “for”:

foreach (DetailType detail in DetailView.Select())
{
    head.TotalPlanAct += detail.PlanActValue;
}

The other one would be to use a view with an aggregate, so that it would directly return you the total value and you won’t have to loop in your code to calculate it.

2
votes

finnaly i'm using PXDBScalar and it's works on unbound field.