Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

SETCURRENTKEY bug?

(0) ShareShare
ReportReport
Posted on by 750

In NAV 2015 I by accident used SETCURRENTKEY with a key that not existed. When I ran the codeunit no errors occured.

When I look at the documentation it says

"If no keys can be found that include the fields that you specify, the return value is FALSE. If you do not test the return value, a run-time error occurs. If you do test the return value, the program will continue to run even though no key was found."


If I create a simple table with id and name the code below will return True (in 2013 R2 and 2015) no matter what field I select as key. In 2009 it behaves as the documentation.

keyworking := r.SETCURRENTKEY(name2);
MESSAGE(FORMAT(keyworking));

Is this a bug or is the documentation not up to date?

*This post is locked for comments

  • Suggested answer
    Tharanga Chandrasekara Profile Picture
    23,116 on at
    RE: SETCURRENTKEY bug?

    With the introduction of Dynamics NAV 2013 R2 version interactive soring feature was introduced to Dynamics NAV. Therefore you no longer required to define a key in the table level to sort it in the run time. You can sort the data with any field.

  • Verified answer
    Rajasekhar@MS Profile Picture
    5,569 on at
    RE: SETCURRENTKEY bug?

    Hi

    From Nav 2013 R2 with the Introduction of Interactive soring feature, it is no longer required to define a Key on a table to sort data. SetCurrentKey no longer requires a Key to be created in the table.

    refer the below for details

    https://markbrummel.wordpress.com/2013/10/23/nav-2013-r2-keys-keygroups-and-setcurrentkey/

    https://markbrummel.wordpress.com/2013/09/10/nav2013r2-interactive-sorting/

     Its not a bug, seems to be the document not updated

    Best Regards

    Rajasekhar.Y

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2

#1
mmv Profile Picture

mmv 2

#1
Amol Salvi Profile Picture

Amol Salvi 2

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans