DrillDown with RecordRef

efv@inecta.comefv@inecta.com Member Posts: 3
edited 2011-12-17 in Navision Attain
Hi there, I am using RecordRef and FieldRef to get values from tables that the user specifies. He enters the table number into a setup table and the field to get the value from. I need to allow him to do a DrillDown with only the Table number to go on. I don't want to create a bunch of Record Variables or Form Variables. And using FORM.RUNMODAL(0); Requires a Record Variable. Is there maby some way I can create a Record Variable on the fly??

Hope somebody can help me out.
Elmar Freyr Vidisson
Navision Attain Certified Programmer

Comments

  • eromeineromein Member Posts: 589
    nope!

    Well not yet that is, how knows what the future will bring.

    I made a sample one time. Maybe it's off any help.

    downloadable here: http://www.mibuso.com/dlinfo.asp?FileID=276
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • efv@inecta.comefv@inecta.com Member Posts: 3
    Thank you for your quick response.

    The only thing that is really missing is the ability to do something like FORM.RUNMODAL(0,Customer); Just instead of having it the table CUSTOMER, I need to have it a RecordRef to that Table, without creating a variable. Maby FORM.RUNMODAL(0,RecordRef.NAME); I tried this along with many variations, and nothing seems to work. Any ideas of how to acomplish this?
    Elmar Freyr Vidisson
    Navision Attain Certified Programmer
  • eromeineromein Member Posts: 589
    Nope!

    Well not yet that is, how knows what the future will bring ;)

    Really, this is a big problem. I made lot of really nice applications based on recordrefs. But I always have to make a codeunit or a function to show a form per record....

    You have to do something like this:
    CASE RecordRef.NUMBER OF
      DATABASE::Customer :
        BEGIN
          Cust.SETTABLE(RecordRef);
          FORM.RUNMODAL(0,Cust);
        END;
      ESLE
        ERROR('No form defined'); // Should be a text constant
    END;
    

    * Code have'nt been tested!
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Matjaz_SegaMatjaz_Sega Member Posts: 3
    Not sure about the older versions, but in NAV 2009 R2 this can be done with the use of Variant datatype:
    rRef: RecordRef;
    var: Variant;
    
    rRef.OPEN(18); //Customer
    var := rRef;
    FORM.RUNMODAL(0,var);
    


    The only problem is that you can not apply filters to the record, because they get lost when you assign RecRef to the Variant variable. First record in the filter DOES get selected though. Example below:
    rRef.OPEN(18); //Customer
    rRef.FILTERGROUP(5);
    fRef := rRef.FIELD(2); //Customer.Name
    fRef.SETFILTER('T*');
    rRef.FILTERGROUP(0);
    rRef.FINDSET;
    var := rRef;
    FORM.RUNMODAL(0,var); //Form shows all records but is focused on the first that fits in the filter 'T*'.
    


    I hope that helps someone else too.
  • mdPartnerNLmdPartnerNL Member Posts: 802
    Not sure about the older versions, but in NAV 2009 R2 this can be done with the use of Variant datatype:
    rRef: RecordRef;
    var: Variant;
    
    rRef.OPEN(18); //Customer
    var := rRef;
    FORM.RUNMODAL(0,var);
    


    The only problem is that you can not apply filters to the record, because they get lost when you assign RecRef to the Variant variable. First record in the filter DOES get selected though. Example below:
    rRef.OPEN(18); //Customer
    rRef.FILTERGROUP(5);
    fRef := rRef.FIELD(2); //Customer.Name
    fRef.SETFILTER('T*');
    rRef.FILTERGROUP(0);
    rRef.FINDSET;
    var := rRef;
    FORM.RUNMODAL(0,var); //Form shows all records but is focused on the first that fits in the filter 'T*'.
    


    I hope that helps someone else too.


    Nice trick,
    But how to get the selected value back?
  • Matjaz_SegaMatjaz_Sega Member Posts: 3
    Hm, yes, I'm sorry, the original problem here is different than the one I had - I only needed to open the form, not to actually make lookup.

    I have researched a bit further but haven't been able to retrieve the selected value back. I guess that you still need the record variable to make a lookup... :(
Sign In or Register to comment.