Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Index out of bounds

Posted on by Microsoft Employee

I've got users running report ID 50024 Confirmation Letter from a button it allows them to select print but then quickly throws an 'index out of bounds' error.

I'm debugging the report to find which specific index is out of bounds by stepping through the process using the NAV debugger. 

Wanted to see what insight you pros have

Thanks, 

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Index out of bounds

    Thanks Bodhi!!

    the DataItemLink needed to be completed!!!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Index out of bounds

    Posted a summary of this question over on mibuso: forum.mibuso.com/.../index-out-of-bounds-report-failing

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Index out of bounds

    DataItem link property for Resource Schedule Entry is <undefined>

    Which Report trigger should I put filters on?

  • Verified answer
    Bodhi Profile Picture
    Bodhi 554 on at
    RE: Index out of bounds

    Before Preview the report, may add filters, like work order No or date, to narrow the records range

    Or the DataItemLink of the Properties for DataItem Resource Schedule Entry should be maintained

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Index out of bounds


    doing some sleuthing with the debugger and some MESSAGE statements. I've narrowed the issue down to the code in the two triggers down below. What ends up happening is MESSAGE('1'); fires followed by MESSAGE('2'); over and over and over and over until an error pops. 

    I even upped the array dimensions to 50000 took ages but the same error triggered so it's got to be some code problem sending it on a forever loop?


     

    Resource Schedule Entry - OnAfterGetRecord()
    // Skip duplicate records
    MESSAGE('1'); // added by Rob 


    IF (EM_Duplicate("Work Order No." + '-' + FORMAT(Date) + '-'+ FORMAT(screening_start) +'-'+ FORMAT(screening_stop))) THEN
    CurrReport.SKIP;


    MESSAGE('2'); // added by Rob


    VAR_Index += 1;
    VAR_RSEArray[VAR_Index] := "Work Order No." + '-' + FORMAT(Date) + '-'+ FORMAT(screening_start) +'-'+ FORMAT(screening_stop);

    Resource Schedule Entry - OnPostDataItem()

    EM_Duplicate(CONST_RSE : Text[60]) LOCAL_Duplicate : Boolean
    // Checks if duplicate shift exists, skip if found
    LOCAL_Counter := 1;
    LOCAL_Duplicate := FALSE;

    REPEAT
    IF CONST_RSE = VAR_RSEArray[LOCAL_Counter] THEN
    LOCAL_Duplicate := TRUE
    ELSE
    LOCAL_Counter := LOCAL_Counter + 1;

    UNTIL (LOCAL_Counter > VAR_Index) OR (LOCAL_Duplicate= TRUE);

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Index out of bounds

    The debugger breaks at an OnAfterGetRecord() trigger with this code, the pointer at the second line.

    VAR_Index += 1;
    VAR_RSEArray[VAR_Index] := "Work Order No." + '-' + FORMAT(Date) + '-'+ FORMAT(screening_start) +'-'+ FORMAT(screening_stop);

    Thinking VAR_RSEArray was perhaps too small. I checked its properties and found its dimensions to be 300. I bumped it up and tested the report again. No dice. The error still occurs with the the dimensions of that array bumped all the way to 1000.

    Now I suppose report logic is the culprit?

    I'm trying to figure out where in the report is repeating over 1k times using break points in the debugger.

    Any advice on taking this to the next steps?

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: Index out of bounds

    As suggested by Suresh you need to check any Array is used in program. Activate debugger and check.

  • Suggested answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: Index out of bounds

    Hello,

    As per other members suggested go through, And also check your logic you might be used some bad/extra looping. its also caused to go one more time.

  • Suggested answer
    Alexander Ermakov Profile Picture
    Alexander Ermakov 28,094 on at
    RE: Index out of bounds

    You have a customized report. As Suresh mentioned, it is because the data is greater than the array dimension. Take your variable, go to property and increase the dimension size.

  • Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Index out of bounds

    Rob,

    You will get that error because of Array Varaibles and if the dimension on that variable does match with dimension you are assigning. Ex: if you create a array to store 10 values but trying to assign 11th.

    Debugger should point you that variable and you just need to change the dimension or checkthe logic why for this user it is out of index.

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!

Community AMA December 12th

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans