Creating a table at runtime

MasterOfDragonsMasterOfDragons Member Posts: 18
Hello,

after creating a table via the Object table, I can't add fields to it, neither manually nor through a codeunit. Where's the problem :-k

Thanks in advance
Master of Dragons

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    What do you mean by adding fields via a codeunit? This is impossible.

    What message do you get by trieing manualy?
  • DenSterDenSter Member Posts: 8,307
    Don't think that's going to work in regular C/AL, maybe if you use ADO and connect directly to SQL Server and hack your way into the system. I guess if you are really dead set to hack your way into the object table, which nobody recommends because that's where the objects of your company's mission critical ERP system are stored, then what you could do is turn on the SQL Profiler and manually create a table within Navision and the profiler will tell you exactly what SQL statements are run. Then you could try to recreate that with some ADO programming.

    You have to realize though that by doing that you jeopardize the entire system. If you corrupt the data (by that I mean make it so that Navision doesn't know what to do with it) then your system might suddenly stop working altogether.
  • MasterOfDragonsMasterOfDragons Member Posts: 18
    So, uhm..., is there any safe way of creating a table? :(
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    To create a table, open the object designer, goto tables and click NEW.
  • MasterOfDragonsMasterOfDragons Member Posts: 18
    Well, I already knew of that way. What I meant was a way to create a table via the code...
    But I guess there isn't any ](*,)
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Well, not that I know of...sorry.

    What is it that you need it for? Maybe we can think of some alternative...
  • MasterOfDragonsMasterOfDragons Member Posts: 18
    What I want is a form where I enter the ID of a table, a directory and filename, and the ID and name for a new codeunit. Then I click on a button and the form generates a codeunit (in the form of a txt file which can be imported) that should create a duplicate of the table and fill it with the same lines as the original. This is so that you can create a table in your own system and then easily transfer it to a customer's. I know that you could simply ex- and import the table, but this would only be the first step. When it is finished, it would be expanded to create a single codeunit for multiple tables.
    I hope this is understandable :oops:
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Yes, we did a similar thing in VB creating conversion tables/forms/dataports and reports that can be imported via txt files.
  • kinekine Member Posts: 12,562
    Hello,

    after creating a table via the object table, I can't add fields to it, neither manually nor through a codeunit. Where's the problem :-k

    Thanks in advance
    Master of Dragons

    If you are trying to create objects with C/AL code directly into Object table, and you want add fields through Field table, forget it. It is not possible...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • MasterOfDragonsMasterOfDragons Member Posts: 18
    Nevermind, I just understood the task wrong. It isn't even supposed to create tables... just copy the lines #-o

    Thanks to all of you, who tried to help me!
Sign In or Register to comment.