Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Opening Balance is always showing zero in output

Posted on by 1,835

Dear Experts,
I prepared the mail functionality for daily posted general voucher entry in navision system.
Here I have tried to show the opening balance in 'Shift Start' but it is always showing the zero.
Please help me resolve this issue. The Code is below:

Mail.CreateMessage('MKU Limited','nav@mku.com','test2@mku.com','General Voucher Summary','',TRUE) ;
Mail.AppendBody('Dear Sir / Madam,');
Mail.AppendBody('<br>');
Mail.AppendBody('Please Find The General Voucher Details:');
Mail.AppendBody('<br><br>');
Mail.AppendBody('<table border="1">');
Mail.AppendBody('<tr>');

Mail.AppendBody('<th>Document No.</th>');
Mail.AppendBody('<th>Posting Date</th>');
Mail.AppendBody('<th align="left">Description</th>');
Mail.AppendBody('<th>Debit Amount</th>');
Mail.AppendBody('<th>Credit Amount</th>');
Mail.AppendBody('<th>Unit</th>');
Mail.AppendBody('</tr>');

GLEntry.RESET;
GLEntry.SETFILTER(GLEntry."Posting Date",'%1..%2',0D,TODAY-1);
GLEntry.CALCSUMS(Amount);

IF GLEntry.Amount > 0 THEN
OpeningDRBal := GLEntry.Amount;
IF GLEntry.Amount < 0 THEN
OpeningCRBal := -GLEntry.Amount;

Mail.AppendBody('<th align="right" colspan="3">Opening Balance</th><th colspan="3">'+FORMAT(OpeningDRBal)+'</th>');
Mail.AppendBody('</tr>');

recGLEntry.RESET;
recGLEntry.SETRANGE(recGLEntry."Posting Date",TODAY);
recGLEntry.SETFILTER(recGLEntry."Source Code",'GENJNL');

IF recGLEntry.FINDFIRST THEN
BEGIN
REPEAT
Mail.AppendBody('<tr>');
Mail.AppendBody('<td>'+FORMAT(recGLEntry."Document No.")+'</td>');
Mail.AppendBody('<td align="center">'+FORMAT(recGLEntry."Posting Date")+'</td>');
Mail.AppendBody('<td align="left">'+FORMAT(recGLEntry.Description)+'</td>');
Mail.AppendBody('<td align="right">'+FORMAT(recGLEntry."Debit Amount")+('.00')+('</td>'));
Mail.AppendBody('<td align="right">'+FORMAT(recGLEntry."Credit Amount")+('.00')+('</td>'));
Mail.AppendBody('<td align="center">'+FORMAT(recGLEntry."Global Dimension 1 Code")+'</td>');
Mail.AppendBody('</tr>');
UNTIL(recGLEntry.NEXT=0);
END;

Mail.AppendBody('</table>');
Mail.AppendBody('<br>');
Mail.AppendBody('<b>From</b>');
Mail.AppendBody('<br>');
Mail.AppendBody('NAVISION ERP System');
Mail.AppendBody('<HR>');
Mail.AppendBody('This is a system generated mail. Please do not reply to this email ID.');
Mail.Send;

*This post is locked for comments

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: Opening Balance is always showing zero in output

    Write as follows for opening balance

    You can take opening balance from G/L Account

    GLAccount.SETRANGE("Date Filter",0D,GETRANGEMIN("Date Filter")-1);

    GLAccount.CALCFIELDS("Net Change");

    OpeningBalance:="Net Change"

    As well as check whether amount is there on the given date and if it is for particular G/L Account then filter for that account.

  • manish.yadav Profile Picture
    manish.yadav 1,835 on at
    RE: Opening Balance is always showing zero in output

    I have attached the output as screenshots.

    0820.uu.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans