Thursday, April 25, 2019

X++ | Change EDT of a table field

Sometimes we probably need to change EDT of a table field because lack of well designed or best practice. However after stored some data in a table, then it cannot be done only by renaming the EDT like we usually do when creating a new table.

The following instruction are one of possible practice I tried. I got the idea from Martin DrĂ¡b in this link https://dynamicsuser.net/ax/f/developers/48678/table-field-change.

    - list all field will be changed             
    - create all new EDT                           
    - backup table data (just in case)
    
    **Note: the following 4 steps need to done respectively shortly in IDE.
    - rename field name to something like OLD_xxx
    - add new field (with old name xxx)
    - build (for d365FO or compile in other previous versions)
    - synchronize with database

    - copy value from old to new field (this is my first thought, however no need as the new created field already stored the old data)
    - delete old field (OLD_xxx)
    - delete old EDT

**Note1: This is case of String EDT, in other cases (i.e. Integer -> Real) you might do some further test.
**Note2: Before deleting old field. If the field you are changing is being used as one of table index. You need to check that index also, because that index field also is changed to OLD_xxx. That you need to correct as well.
**Note3: Before deleting old field. Check table property like titlefield also, it also can still keep OLD_xxx.

Until the next post!

No comments:

Post a Comment