Company ID and Company Name

cloudninecloudnine Member Posts: 25
Hi guys...

Just a question...

Is there a Company ID in Navision or is Company Name itself is the ID for a company in Navision...

Thanks...

Comments

  • MissesMagicMissesMagic Member Posts: 39
    Hi cloudnine,

    I just know CompanyName, no ID.
    (even that you have to use Name for Changing Company)
    -> take a look at Table 2000000006 (Company)
  • WaldoWaldo Member Posts: 3,412
    FYI,

    you can create an extra column in that table (CompanyNo) if you want ... and even write some validation-code behind it.

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • MissesMagicMissesMagic Member Posts: 39
    That´s an idea,
    but let NAV make it for you with autoincrement

    - I don´t think you always want to Insert & Delete Companies :D
  • WaldoWaldo Member Posts: 3,412
    In codeunit 2 you can write code that fills in the company ID in the new field of table "company"

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • MissesMagicMissesMagic Member Posts: 39
    Hej Waldo,

    I ment,
    Just make a new Int-Field and chose Autoincrement = TRUE.
    That´s all and you don´t need Code at all!

    Sure - I know the order of this field is not equal to the order of Companies if you don´t insert them in alphabetical order, but if you do so, why writing Code?

    And one Company always has the same ID during existing in database...

    But I think cloudenine just wanted to know IF this ID exists??
    And this question we have already answered =D>

    @Waldo:
    Just interested: What code dou you would write?
    giving an example:
    Adding following Companies (in writting Order):
    A , X, L, B
    what ID they have after your code?
  • cloudninecloudnine Member Posts: 25
    Thanks MissesMagic for answering my question...

    Waldo thanks also to you but we dont want to alter the navision tables/database...

    Thanks
  • WaldoWaldo Member Posts: 3,412
    @Waldo:
    Just interested: What code dou you would write?

    :-k
    Just from the top of my head ...
    - add new integer field to company table
    - add key on this field
    - OnInsert write code:
    - sort on integer field (Seperate record variable :| )
    - get last ID
    - Generate New ID
    - Add this ID to current record

    giving an example:
    Adding following Companies (in writting Order):
    A , X, L, B
    what ID they have after your code?
    A=1
    X=2
    L=3
    B=4

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • MissesMagicMissesMagic Member Posts: 39
    That are the IDs I expected.

    You get the same result, when you just set the "AutoIncrement"-property of Field "ID" to yes :wink:
  • WaldoWaldo Member Posts: 3,412
    True :oops:
    but I don't like Autoincrement...

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
Sign In or Register to comment.