Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Add Value to the next of last Value

Posted on by 3,027

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

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

    Hi

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

    Thanks

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 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.

  • jsshivalik Profile Picture
    jsshivalik 3,027 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

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

    Hi

      It is not working

    Thanks

  • Suggested answer
    Binesh Profile Picture
    Binesh 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;

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 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.

  • jsshivalik Profile Picture
    jsshivalik 3,027 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
    Binesh Profile Picture
    Binesh 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
    jsshivalik 3,027 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
    Amol Salvi Profile Picture
    Amol Salvi 18,694 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.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,064 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans