recordref and recordID

txerifftxeriff Member Posts: 500
Hi all,

i´d like to loop into the field table for all the option type fields and then retrieve the option values from each field.
Well, im trying to do something a bit complex, hope you can help. Here it goes:
tobjeto is recordref type variable.
tfield is the navision field table.

...

      TField.RESET;
      TField.SETRANGE(Type,TField.Type::Option);
      IF TField.FINDSET THEN
        REPEAT
          evaluate(vnotabla,format(tfield.tableno));
          tobjeto.open(vnotabla);
          Tobjeto.SETPOSITION(
...
...


Im getting confused with recordref and record id.

How do I set the recordref to a regular record type variable?

if you have a better idea to solve this, i´d apreciate your comments. :lol:
thanks! :thumbsup:

Comments

  • ppavukppavuk Member Posts: 334
    RecordRef.RESET;
      RecordRef.OPEN(TAbleNo); //open a table
      RecordRef.CURRENTKEYINDEX(6); //select key no. 6
      FiledRef := RecordRef.FIELD(26); //select filed no 26
      FiledRef.SETRANGE(filterstring); setfilter on filed 26 
      IF RecordRef.FINDSET THEN 
       do whatewer you want
    

    You can also get RecRef by record ID
    something like
    RecordRef.GET(MyRecordID) //MyRecorID must be RecordID type  variable
    

    Hope this helps
  • txerifftxeriff Member Posts: 500
    ppavuk wrote:
    RecordRef.RESET;
      RecordRef.OPEN(TAbleNo); //open a table
      RecordRef.CURRENTKEYINDEX(6); //select key no. 6
      FiledRef := RecordRef.FIELD(26); //select filed no 26
      FiledRef.SETRANGE(filterstring); setfilter on filed 26 
      IF RecordRef.FINDSET THEN 
       do whatewer you want
    

    You can also get RecRef by record ID
    something like
    RecordRef.GET(MyRecordID) //MyRecorID must be RecordID type  variable
    

    Hope this helps


    thanks, but not sure if its what i need.

    im looping in a series of tables, so i dont know what key it is.
    I would need to caption each value of any option type field, but if i loop into each row i would only see those values that have been used , not all the option values. Also note that it would be very slow, looping all the rows from a table to retrieve all the posible used option values.

    I know it sounds a bit complex.
  • MBergerMBerger Member Posts: 413
    The following code will message you all the optioncaptions in Table 27, adapt for your own use.

    object : record Object
    fields : record Field
    recref : RecordRef
    fieldref : FieldRef
    object.setrange(type,object.type::table) ;
    object.setrange("company name",'') ;
    object.setrange(Id,27) ;
    if object.findset then
      repeat
        fields.reset ;
        fields.setrange(tableno,object.ID) ;
        fields.setrange(Type,fields.type::option) ;
        if fields.findset then
          repeat
            recref.open(object.ID) ;
            fieldref := recref.field(fields."No.") ;
            message('Table : %1, Field : %2, Optioncaption : ''%3''',object.id,fields."no.",fieldref.optioncaption) ;
            recref.close ;
          until fields.next = 0 ;
      until object.next = 0 ;
    
  • txerifftxeriff Member Posts: 500
    thanks a lot!

    You wont believe but just found in another forum the solution
Sign In or Register to comment.