Dynamic TableRelation.

kirkostaskirkostas Member Posts: 127
I have a Tabular-Type form link to Fields table.
I open this form from another form filtering the records for table 18 Customer.
I have an extra column (text 250 chars) where you can type any value for any field you like. For example you can type for field 91 a value.
Field 91 is the Post Code field in customer table.
I want to add some code in OnLookup trigger to open the related table to be able to select records. For example I want to be able to press F6 button in Post Code field and open the Post Code table to select a value.
I used RecordRef and FieldRef types, and I can retrieve the Table Relation for Post Code field in Customer table which is 225 but I am stack, I dont know how to make it work as a Lookup form.
//OnLookup - CONTROL
RecRef.OPEN(field.TableNo); //table 18 Customer
FldRef := recref.field(field."No."); //field 91 Post Code
if FldRef.RELATION > 0 then //returns Table No 225 which is the Post Code table
  //here it must open the related form and get the value
kirkostas

Comments

  • kinekine Member Posts: 12,562
    This cannot be done in easy way. Sorry. I will like such a functionality too, but no way. You need to hardcode opening the lookup form for each table. And this is huge task if you want to work with all tables... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DaveTDaveT Member Posts: 1,039
    Hi Folks,

    This problem interested me so I had a look - like you both I looked at the field table with no joy but I then decided to RTFM and I found this.....
    FORM.RUN(Number [, Record] [, Field])
    Number

    Data type: integer

    A number which identifies a form object. If you enter zero (0), the system displays the default lookup window for the current form. You can use the Symbols option on the View menu to choose from a list.

    i.e.

    form.run(0, Custrec ); - runs the customer list
    form.run(0, LocationRec ); - runs the location list

    Unfortunately it doesn't run on a recordref but hopefully it's of some help to you.
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • kinekine Member Posts: 12,562
    Yes, 0 is lookup form, but as you wrote, it is not working with RecordRef and this is the main point... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kirkostaskirkostas Member Posts: 127
    Thank you guys, if I find a solution to the problem will share with you.
    kirkostas
Sign In or Register to comment.