Single record tables

freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
Now it is my turn to ask a question to all the NAV experts here...

What is the preferred mechanism in NAV to limit a table to have only one record?

I can of course create a field, which always is 0 and set this to be the primary key - but is the best way?
Freddy Kristiansen
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk

The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.

Answers

  • bbrownbbrown Member Posts: 3,268
    The standard NAV approach is to handle it in the form. You can see this in the various setup forms. There is nothing that prevents you from adding multiple records to a setup table via Object Designer. I think it's debateable whether this is the best approach.
    Form - OnOpenForm()
    RESET;
    IF NOT GET THEN
      INSERT;
    
    There are no bugs - only undocumented features.
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV 2009' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ara3nara3n Member Posts: 9,256
    I believe a new property in the Table called MaxNoOfRecord.

    The default would be 0 = unlimited and users can set it to 1.



    through code you could add OnInsert trigger.

    If not ISEMPTY then
    Error('You cannot insert more than 1 record into the table');
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.