web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Add Value to the next of last Value

(0) ShareShare
ReportReport
Posted on by 3,099

Hi

  In Array How to Add Value to the next of last Value . I have below code. I want if Account No not found n array then it should be appended to the array.

Below is he code on after get record

ctr := 1;
WHILE (Ctr <= 10) DO BEGIN IF AccountName[Ctr] = GLEntry."G/L Account No." THEN BEGIN AccountValue[Ctr] += GLEntry.Amount; found := TRUE; END; Ctr += 1; END;

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at
    RE: Add Value to the next of last Value

    Do you want to put in same array or another array . You can put else condition and add the value in array.

  • jsshivalik Profile Picture
    3,099 on at
    RE: Add Value to the next of last Value

    Hi

      In Array if Account no not found then i want to append in that array . If Found then i am adding Amount Value at that index.

    Thanks

  • Suggested answer
    Binesh Profile Picture
    7,885 on at
    RE: Add Value to the next of last Value

    Hello,

    put some example, what you want, so we can easily understand ur query.

    I think you want , if GLEntry."G/L Account No." is matched with AccountName[Ctr]  then you are adding amount value, else you want to skip, If it so then just Re-write your code like:

    ctr := 1;

    WHILE (Ctr <= 10) DO BEGIN

        IF  AccountName[Ctr] = GLEntry."G/L Account No."  THEN BEGIN

             AccountValue[Ctr] += GLEntry.Amount;

             found := TRUE;

             Ctr += 1;

        END;

    END;

    if it not fulfill ur requirement then post your whole code with some example.

  • jsshivalik Profile Picture
    3,099 on at
    RE: Add Value to the next of last Value

    Hi

     Below is the code. I am using only 1 Array . U know what actually i want.

    OnPreReport()
    g_ctr := 1;
    
    G/L Entry - OnAfterGetRecord()
      Ctr := 1;
          WHILE (Ctr <= 10) DO BEGIN
            IF  AccountName[Ctr] = GLEntry."G/L Account No."  THEN BEGIN
              AccountValue[Ctr] +=  GLEntry.Amount;
              found := TRUE;
    
            END;
            Ctr += 1;
          END;
    
          IF NOT found  THEN BEGIN
            AccountName[g_ctr] := GLEntry."G/L Account No.";
            AccountValue[g_ctr] := GLEntry.Amount;
            g_ctr += 1;
          END;


    Thanks

  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at
    RE: Add Value to the next of last Value

    So now what is the issue with this code ? Are you not getting any value in array ?

    Activate debugger and check where you can easily find the execution of program.

  • Suggested answer
    Binesh Profile Picture
    7,885 on at
    RE: Add Value to the next of last Value

    Hello,

    You have to write something like:

    OnPreReport()

    G/L Entry - OnAfterGetRecord()

    Ctr := 1;

    WHILE (Ctr <= 10) DO BEGIN

    IF  AccountName[Ctr] = GLEntry."G/L Account No."  THEN BEGIN

     AccountValue[Ctr] +=  GLEntry.Amount;

    END ELSE BEGIN

     AccountName[Ctr] := GLEntry."G/L Account No.";

     AccountValue[Ctr] := GLEntry.Amount;

    END;

    Ctr += 1;

    END;

  • jsshivalik Profile Picture
    3,099 on at
    RE: Add Value to the next of last Value

    Hi

      It is not working

    Thanks

  • jsshivalik Profile Picture
    3,099 on at
    RE: Add Value to the next of last Value

    Hi

     IN the below code it is showing only values of first record. IT is not summing up if found

    2L30 -8532

    2L20 -8532

    3A40 111864

          0

          0

         WHILE (Ctr <= 10) DO BEGIN

           IF  AccountName[Ctr] = GLEntry."G/L Account No."  THEN BEGIN

             AccountValue[Ctr] +=  GLEntry.Amount;

             found := TRUE;

           END;

           Ctr += 1;

         END;

         IF NOT found  THEN BEGIN

           AccountName[g_ctr] := GLEntry."G/L Account No.";

           AccountValue[g_ctr] := GLEntry.Amount;

           g_ctr += 1;

         END;

    Thanks

  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at
    RE: Add Value to the next of last Value

    Which value you want to sum up and where? If want sum up then don't  you need to write your code accordingly..

    Debug the code and do appropriate changes.

  • Verified answer
    jsshivalik Profile Picture
    3,099 on at
    RE: Add Value to the next of last Value

    Hi

     Resolved. Code was correct . In RDLC Last() was to be used.

    Thanks

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans