New field in table

Hi guys,

I have a problem. I need to create new field in table via code. It’s possible in NAV? I was working with AX, everything was simple, I can simply execute sql query. It’s possible in NAV? Or maybe I can somehow export table fob file and add there new field? Can anyone give me suggestion ? Thanks.

Welcome to DUG !!

No, It cant be done in Navision. Can you please elaborate what do you exactly want to do.

Thanks

Gaurav

Welcome to DUG !!

No, It cant be done in Navision. Can you please elaborate what do you exactly want to do ?

Thanks

Gaurav

Thanks. For example I have table something like “Test table” and there are field “Amount” := 2,7, I need to convert that field to “Amount” := 3, that’s ok, but before I convert field I need to create historical field via code and set it “Historical Amount” := 2,7. And result is that I have converted “Amount” field and I have new field “Historical Amount” with old field “Amount” value. Did you get it ?

You can update the Historical Amount field with Amount via SQL Query if both the field are not flowfield.

If the field is flow field then you have to update the original table from where the values are taken in the field.

Whenever you need to alter the definition of a table object in NAV, you are always advised to make those changes using the Object Designer. It is possible to export the table object to a text file (provided you have the license for it), make edits to that exported text file, then import the text file and compile the object. That is possible, but it’s generally not the best way of doing it, and the method introduces a whole host of possible faults, errors, failures, etc. And it usually takes longer that just doing it in Object Designer. So, if you’re just adding a field to your Test Table, use the object designer.

As to the business case for adding this field, I can only say that you would be best served to really understand the objective for adding the field and saving the original values, and the implications your solution will have for your users, the data consumers, the ongoing care and feeding of the database, and the overall system performance. Remember that the right answer isn’t always the one that’s the easiest to say.

On your questions related to using SQL queries and scripts to do these tasks, I only observe that people try to use their favorite tool for every task. If you’re a SQL expert but new to NAV development, the tendencies are to try to use SQL to do all the work. Remember that NAV existed long before it existed on SQL, and while there are some processes that are more efficient in SQL, most of the business logic that forms the foundation of the application is best built and maintained within the NAV development environment. It would be to your advantage to become expert in that environment as well.

Just my humble opinion. I hope it’s of some use to you.

Ok guys thanks for advices, but yesterday I didn’t find way how to do this, so I decided to create fields with object designer :slight_smile: I guess it took less time than I would find the way how to do this… And yes I’m new to NAV development… I was working with AX… I hate NAV editor :x But developing is easy :slight_smile: