Search code examples
sqlnavisiondynamics-navmicrosoft-dynamics-nav

Is possible do Select * form DynamicValue to perform a query like this in Navision?


Is possible do Select * form DynamicValue to perform a query like this in Navision?

Thanks in advance


Solution

  • To perform a sql query li this select * from DynamicValue You must do something like this.

    Imagine that you have a table and you are going to show the data in a page or form.

    Variables:

    RecDynamicValue (Table).
    PagDynamicValues (Page).
    

    Code:

    RecDynamicValue.RESET; //Clean filters
    CLEAR(PagDynamicValues);
    PagDynamicValues.SETTABLEVIEW(RecDynamicValue); //Set RecDynamicValue (Table)
    PagDynamicValues.RUN; (Open Page)
    

    In this code when page is open you can see al records from DynamicValue table like a Select * from DynamicValue.

    If you need perform a loop for all records from DynamicValue table in code try this:

    RecDynamicValue.RESET;
    IF RecDynamicValue.FINDSET THEN REPEAT //Repeat clausule for a loop
      //Loop...
      //Loop...
      //Loop...
    UNTIL RecDynamicValue.NEXT = 0; //Repeat until last value
    

    In all cases first you need declare a variable, SubType = Record and specified ID or name of record. You can not change the value of the table variable by code.

    But perhaps you can use RecordRef function to do that.

    For example:

    RecRef.OPEN(27); //Id of ItemTable    
    RecRef.FINDFIRST;
    FldRef := RecRef.FIELD(3); // Item.Description;
    FldRef.VALUE('New description');
    RecRef.MODIFY;
    

    In your case your DynamicValue is parameter to RecRef.OPEN("Your Dynamic Value") here you need specified value ID of your table.

    You can also perform a loop using RecorRef.