X++ code using SysComputedColumn to use aggregate function "sum" in D365FO
Chaitanya Golla
17,225
Hi,
In this post, we will view the code to use aggregate function "sum" of SysComputedColumn in D365FO.
Please refer to my earlier post to know the details about the view DAXCustomerTransMeasures.
Step 1: Created a method "computeBalance" to display the difference of amounts between the sum of AmountCur and sum of SettleAmountCur to know the balance amount for a customer for different transaction types using sum method of SysComputedColumn.
public static str computeBalance()
{
TableName viewName = tableStr(DAXCustomerTransMeasures);
str amountCurStr = SysComputedColumn::returnField(viewName, identifierStr(CustTrans), identifierStr(AmountCur));
str settleAmtCurStr = SysComputedColumn::returnField(viewName, identifierStr(CustTrans), identifierStr(SettleAmountCur));
str amountCurTotal = SysComputedColumn::sum(amountCurStr);
str settleAmtCurTotal = SysComputedColumn::sum(SysComputedColumn::abs(settleAmtCurStr));
return SysComputedColumn::subtract(amountCurTotal, settleAmtCurTotal);
}
Assigned view method "computeMaxAmount" to the field "MaxAmount".
Step 2: Build the solution. In the table browser able to see the balance amount for a customer for different transaction types.
Output:
Regards,
Chaitanya Golla
*This post is locked for comments