Lookup button

sridharsridhar Member Posts: 171
I have created textbox field (Name) in a "Card Form". I have related the field with a table using "TableRelation" property. Then I have related the field with a "List form" using "LookupFormId" property.

But, when I click the Lookup button of the Name field the list form is opening but when I choose a name from the List form the value is not stored in the Name field of the card form.

So what I have to do. Is that I have to write any code for that?

Comments

  • Captain_DX4Captain_DX4 Member Posts: 230
    The easiest way to get the lookup form to display is to do everything you have up until a point:

    1) Create a field.
    2) Set the table relation property.
    3) Make sure the table you are reading in "Table Relation" has a LookupFormID property set.

    That will make the easiest lookup happen.

    If the LookupFormID isn't going to be able to be used, then I believe you do need to do the assignment in code.
      CLEAR(lookupform);
      lookupform.LOOKUPMODE(TRUE);
      *lookupform.SETTABLEVIEW(lookuprecord);    //Optional line - not always required.
      *lookupform.SETRECORD(lookuprecord);       //Optional line - not always required.
    
      IF lookupform.RUNMODAL = ACTION::LookupOK THEN
        lookupform.GETRECORD(lookuprecord);
    

    The two optional lines are usually required if you are going to set filters to the lookuprecord before performing the lookup. SETRECORD is the compliment to GETRECORD, which are used to set the record the form is selected to, and to get the selected record from the form respectively.

    Hope this helps! Cheers!
    Kristopher Webb
    Microsoft Dynamics NAV Developer
Sign In or Register to comment.