Retrieving data from FlowField and SumIndexField
We have seen how to add FlowFields and SumIndexField; in this recipe, we will see how to calculate these fields using C/AL code.
How to do it...
Create a new codeunit with Object Designer.
Add the following local variables into the
OnRun
trigger:Name
Type
Subtype
GLAccount
Record
G/L Account
GLEntry
Record
G/L Entry
Add the following code into the
OnRun
trigger of the codeunit:GLAccount.GET('8410'); GLAccount.SETRANGE("Date Filter",0D,TODAY); GLAccount.CALCFIELDS("Balance at Date"); GLEntry.SETCURRENTKEY("G/L Account No.","Posting Date"); GLEntry.SETRANGE("G/L Account No.",'8410'); GLEntry.SETRANGE("Posting Date",0D,TODAY); GLEntry.CALCSUMS(Amount); MESSAGE ('G/L Account 8410 Balance at %1\By FlowField : %2 \By SumIndex Field : %3' , TODAY,GLAccount."Balance at Date", GLEntry.Amount)
Save and close the codeunit.
On executing the codeunit, you should see a window similar to the one shown in the following screenshot: