OK, thanks for the clarification Poppins. Knowing that, the short answer to your question is definitely 'Maybe."
The target of your attention for this task would be the Field table. You’d want to add a record to this table to create a new field in an existing table. In older versions of NAV you could write code that would insert a record into that table, effectively reproducing the effect of adding the field via Object Designer. In the latest versions of NAV, the Field table is read-only, so you can’t add a record using NAV code. And, before we even go down the road of what’s possible using SQL script, don’t go there. We all know the dangers of trying to alter the record schema for NAV tables using anything other than the official development tools.
So, if you were using older versions of NAV, and you could code the field insertion, then you’d be left with the task of writing the code that populates the new field with data. And let’s assume for the sake of argument that you couldn’t ride the coat tails of the TRANSFERFIELDS command in a posting routine. The challenge here is that you’d be writing code to populate a field that, at compile time, wouldn’t yet exist. So, if you referred to it literally, you’d get a compile error. To get around that, you’d have to make use of RecRef and FieldRef. In really old versions of NAV, when those data types were fairly new, they weren’t yet stable and sometimes produced unusual results. So there would be a limit to how far back in the version history you could go and still hope for predictable results.
But all is not lost, there are still options to accomplish the objective within the given limitations. Rather than making the new field an element of the record structure, re-vision the data architecture and make the record definition itself into data. In that way, your actual record would be very brief … PK, FieldName, FieldType, Value, in the abstract. Then, to create a new ‘field’, you’d just add a record. To conceptualize the architecture, imagine the challenge of developing a universal method for storing a person’s name. In the US, we have a 3-field convention - FName, MName, LName. That works pretty well here, but if you venture into Mexico, the convention explodes since their culture often produces names with four or more name segments. How would you record those multiple segments in the 3-field US template? You’d typically arbitrarily pick a first and last, then bang all the remaining segments into the MName field, making it all but impossible to search on. To solve that, you’d abstract the record structure into individual records, one for each name segment. There’s a lot of overhead here, and you’d have to write your own routines to manage i/o into a structure like this, but once finished, it would be a nice way to do what you’re up to. There’s already a similar convention in NAV. Take a look at how we handle multiple Customer E-Mail Address values. Rather than continuing to add a new field in the Customer record for extra addresses, the data is stored in an abstracted record, similar to the method I’ve described.
I know that’s a lot of information, and hopefully maybe some of it’s actually useful?
Sounds like a fun project.