add dynamics fields to a table (nav 2013)

Hi dear friends,

Can we add fields to a table dynamicly (at runtime). I know it is not possibile to remove fields dynamicaly.

Hi Sriyantha,

Could you tell us which version of NAV you’re wanting to do this in, and which version of the database you’re using (native vs. SQL)? I only ask because the answers to many technical questions are version-dependent. In this particular case, I think that the question as to whether this can be done pales in comparison to the question as to whether you should.

Without knowing even the first word of your reasons for wanting to do this, it would be my opinion that trying to add fields to tables during runtime is a very bad idea that would involve countless technical considerations and negative side-effects. I’d suggest that you take a fresh look at the business requirement that has led you to contemplate this approach as a viable solution. I would go so far as to suggest that a solution that involved only pencil and paper would be superior to a plan that required modifying table definitions at runtime.

I’m looking forward to hearing why you want to do this though [8-|]

Sorry, just noticed the version information in the message header …

Hi Sriyantha,

No, you cannot add fields dynamically in Navision. At least not if you define at runtime as something which the user can add without using the Development Environment. But you can upload new and changed objects at runtime (IMPORTOBJECTS).

Is the reason for this question an actual request from a user, or is it just part of you learning NAV? If it’s a user request, then please explain a bit more about what it is that they really need. Because a field is not always a field! [;)]

Thanks for reply to boath of you.

This is for me to learn. :slight_smile:

@ Erik

What did you mean by “field is not always a field!” ?

I mean that a field is not always a field in the normal way where it’s a “hard coded” field in a table in a database. It can also be a data based field not created in the table objects.

A short while a go a customer asked to me add additional descriptive “fields” to their items. Different fields based on the item category. I didn’t add the fields as normal fields (since the customer wanted to be able to add more on their own), but as a “template”. Here the customer could add their descriptive “fields” as individual records, just stored in a data table (like item no., field no., field value). So not “real” fields, but it works the same as seen from the customers view.

So that’s the reason why I asked what your request is about, why do you have a requirement where you would like to be able to add fields dynamically? Maybe this “work around” can be used?

I have actually just found out that I’m wrong!

It is possible to add user defined fields dynamically to a Navision table!

I suddenly remembered that I had seen something like this done somewhere. But I wasn’t a 100% sure. So I dived into my archives of old NAV databases and found a copy of the old sub-version of Navision which was called Entrepreneur. This special version of NAV was directed toward the small-business segment and the license didn’t include the table designer. Instead it was possible for the customers through the setup to add fields with their own names and data types. When they said create, then the code inserted the fields directly into the table. This was done using fieldref functionality to insert the new fields directly into the Fields table as new records.

The next problem comes if you also need to display this data to the page and to allow the user to update the information. Because there is no way to dynamically add fields to a page (or form). In Entrepreneur this was done by predefining the control to a number of user defined fields to the form. And then use a special function to get and display the data as well as allowing the user to update the data based on recordref and fieldref functionality.

@ Erik

Thanks for the help.

Yes if I add a field to a table dynamicaly and insert data, then I should be able to display them in a page.

Now I’m clear that it is Impossible. Anyway Thanks for the effort taken. :slight_smile:

Well it is not impossible if you do it using the same “work around’s” as described above. [:)]