how to use GET function to search for a record in a table having many fields in primary key

Hi All

As far as i know GET function works on Primary Key for searching .

Now In my case I am having two fileds in the primary key

and I want to search by using Get function for a record according to the second field of the Primary Key .

Pls tell how to write the syntax for it

Hi Ankit,

Specify the value of all the fields in primary key, for Example if the value of Field1 and Field2 are Value1 and Value2 respectively then use following:

Rec.GET(Value1,Value2);

If the first field is of no importance, then you an’t use GET. You have to use SETRANGE or SETFILTER on that second field and then FINDFIRST/-SET/-LAST. But beware - there is a possibility that you’ll find more than one record…

You can only use GET when you know the value of all primary key fields, and this is not a search, it is a specific retrieval because you know exactly which record you need. When you don’t know all of them, then you follow anfinnur’s advice.

Hi ,

Actually my problem is that I have two fields , one field which is look up to code field of dimension value table so that when i select code from look up ,than in my second field dimension code will come automatically in it but dimension code and code fields are the first and second field of primary key so not able to use GET. and i have no idea abut SETRANGE so can you tell in more descriptive way

Boy you are asking a lot here… What I think you need is to have a senior sit with you, and have them explain the following:

  • Basic table design principles, making sure that they cover what “primary key” means, and cover foreign key (which is called table relationships in NAV table design). Make sure they explain what you need to set a proper table relationship. Also cover default list form, default lookup form, default drilldown form. Also cover flowfields of types lookup and sum.

  • What the difference is between retrieving a record using primary key values and retrieving records based on values other than primary key values (which includes only knowing field values that are part of the primary key but that do not give you ALL primary key field values). Make sure they give you plenty of C/AL examples.

  • The difference between GET (in which case you DO know ALL primary key values) and FINDFIRST/LAST/SET. Make sure you understand the differences between FINDFIRST, FINDLAST, FINDSET (including the meaning of the parameters), and when to use ISEMPTY.

  • Basic NAV form design principles. Make sure they explain what you can accomplish simply by setting the right table relationship, because when you know this, you don’t need to do any programming in most table relationship functionality.

  • Advanced form design, cover when it is appropriate to program OnLookup at the table level or at the form level (most of the time you do this at the table level). Make sure they explain how to filter a record variable, how to display the list form, how to catch the selected record and how to access the fields of the selected record.

I think that should keep you busy for a couple of weeks. Good luck [:D]

This might be the answer…: http://dynamicsuser.net/forums/t/26694.aspx

Hi Ankit,

If any of the above answers solved your problem, then please click “Verify Solution”, so that we know that your question can be closed. It’s also a way for you to say thank you to the member who helped you, and to tell other members which question that helped you out.