I have a problem regarding using the calcfields function to calculate the amount (LCY) of cust. ledger entry for my report, when i retrieve the records with specific parameters then i get a 0 value of amount (LCY). i have tried to use the calcfield as directed in NAV but it seems not working. below is my code:
grec_CustLedgerEntry.RESET;
grec_CustLedgerEntry.SETRANGE(grec_CustLedgerEntry.“Customer Posting Group”,Code);
grec_CustLedgerEntry.SETRANGE(grec_CustLedgerEntry.“Posting Date”,gdt_StartDate,gdt_EndDate);
grec_CustLedgerEntry.CALCFIELDS(“Amount (LCY)”);
IF grec_CustLedgerEntry.FINDSET THEN BEGIN
REPEAT
gdec_PostAmtFrm[k] += grec_CustLedgerEntry.“Amount (LCY)”;
UNTIL grec_CustLedgerEntry.NEXT = 0
END;
I put the codes in the Customer posting group, Body - onPreSection()
Thanks shailesh but you cannot use that function since amount (LCY) is not a field, amount (LCY ) is a flowfield and u can calculate the amount only by calcfields function…
Anna is correct, you have placed the CALCFIELDS before you have even retrieved any records from the database. You can’t expect it to calculate anything if it doesn’t have a record or data to calculate with.