Method to get the primary key from a table

Guga84Guga84 Member Posts: 24
edited 2013-11-07 in Navision Attain
Is there any function to get the fields that are part of the primary key in Navision Attain? Something like getcurrentkey ?

Any idea of how can I develop that?

Thanks.

Comments

  • BeliasBelias Member Posts: 2,998
    CURRENTKEY function.
    but be aware to not use any SETCURRENTKEY BEFORE...
    read help online for more info about CURRENTKEY
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Guga84Guga84 Member Posts: 24
    Thanks,

    I was looking for sth with get...

    Another question now,
    and who could I get the value of this fields?
  • BeliasBelias Member Posts: 2,998
    Guga84 wrote:
    Thanks,

    I was looking for sth with get...

    Another question now,
    and who could I get the value of this fields?

    maybe getposition fits your needs...
    myrec.get(a,b,c);
    message(myrec.getposition);
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Guga84Guga84 Member Posts: 24
    Yes, that's what I need, but this method do not exist in version 2.5.
    Any solution?

    It rings me a bell that it exists a method that you can get the value of a field in a record just knowing the name of the field but I don´t remember.

    My code would be:
    vKey:=record.currentkey();
    while (existKeyField(vKey)) begin
           vKeyField:=getKeyField(vKey);
           vKeyValue:=record.FUNCTION(vkeyField)
    end;
    

    I need FUNCTION.

    Thanks,
  • BeliasBelias Member Posts: 2,998
    :mrgreen: i forgot that getposition is not so old...unfortunately, recordref and fieldref are not stable in your version (if they exist), so i can't imagine a different solution :-k
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Guga84Guga84 Member Posts: 24
    Belias wrote:
    :mrgreen: i forgot that getposition is not so old...unfortunately, recordref and fieldref are not stable in your version (if they exist), so i can't imagine a different solution :-k

    Thanks anyway.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Guga84 wrote:
    Is there any function to get the fields that are part of the primary key in Navision Attain? Something like getcurrentkey ?

    Any idea of how can I develop that?

    Thanks.

    Why do you need this? It might be better to try thinking out side the box and do this another way.
    David Singleton
  • dule0612dule0612 Member Posts: 7
    i had the sam issue, solved with a simple function:

    RecRef.OPEN(parTableNo);
    PrimaryKeyText := FORMAT(RecRef.CURRENTKEY);
Sign In or Register to comment.