How to get field value from VARIANT variable of type record

pedroccdapedroccda Member Posts: 90
I'm trying to obtain fields' value from a variable of type VARIANT of which I know the table ID (the type of record)...but I don't want to declare many variables (one for each type of record in Navision) and then use EVALUATE [-X

I want to write flexible code, that can manage any type of record and read fields values (at least text, integer, decimal and bool )

Is it possible in some other way? And how? #-o

I tried also to use FORMAT(variantVar) and use fileds length and offset to get values but it seems not to work.... I get values but the offset is not correct...

Please help me!!!!!!!! ](*,) ](*,)
Kiki

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Have you tried using RecordRef for this?
  • pedroccdapedroccda Member Posts: 90
    Have you tried using RecordRef for this?

    Yes but the problem is that I have not these record in the database... :-k
    I want t use the data online of the Rec variable, check these data. If all mandatory fields (listed in a configuration table) are filled in then I'll insert the record in the database otherwise I'll give an error message.
    Kiki
  • jjanauskasjjanauskas Member Posts: 49
    pedroccda wrote:
    Have you tried using RecordRef for this?

    Yes but the problem is that I have not these record in the database... :-k
    I want t use the data online of the Rec variable, check these data. If all mandatory fields (listed in a configuration table) are filled in then I'll insert the record in the database otherwise I'll give an error message.

    There is no reason not to use RecordRef, even if record is not inserted in database. Use RecordRef.GetTable([Record of any TableID]) (as far as I remember)...
  • ara3nara3n Member Posts: 9,257
    You can use variant as a paramater like this, if record reference cannot be used.


    testtable(variant,tableID);
    if TableID = 27 then begin
    ItemRec := variant;
    if ItemRec."No." = '' then
    exit('Item No is required');
    end;
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • DenSterDenSter Member Posts: 8,307
    I don't have access to Navision right now, so I can't check this right now, but check out the methods/properties of a variant type variable. Create a variant variable, open the object browser (F5) and click the right arrow on your variant variable. There is for instance a method called ISTEXT, and when that returns true, you can put the value into a text variable. There are more methods available there.
Sign In or Register to comment.