Move parent table fields to extended table

kjmauriello
Mega Expert

I have taken over an instance where 100+ custom fields have been added to an OOB table.  I would prefer NOT maintaining all of that in the OOB table and want to extend that table and move those custom fields to only reside on the extended table.  How/Can this be accomplished with scripting.

This is how I see it, please let me know if there is a better method.

Option 1:

Execute a script that moves all u_..... fields from parent to child.  This seems to be the easiest since I can execute a Glide query and loop through the fields.  However, GlideDBUtil.promoteColumn promotes from child to parent and does not work on scoped tables (I attempted this sending the last parm as false).  GlideDBUtil.promoteColumn( "parent_table", "child_table", "column_to_move", false);

Option 2:

Create the field on the extended table (giving it a different name) and then run a script to copy the contents into the new field. To get back to the original field name you could then delete the parent table fields and repeat the process on the child table.  All choices, ACL's, ref qualifiers, etc need to be re-created.

If Option 2 is used it would be easier to execute a script to do the field creations on the extended table.  How can this be accomplished?  The table already exists so i would just need to script the add columns.

Any assistance with this would be greatly appreciated.

Kevin

1 ACCEPTED SOLUTION

kjmauriello
Mega Expert

I resolved this in the following manner:

  1. expand dictionary list view to display all columns
  2. filter the list to the custom fields I want to move
  3. export the list to xml
    1. made 2 copies of the file (temp and original)
  4. with the temp xml file
    1. use Textpad to modify the xml (used macros for efficientcy).
      1. changed name extended table name
      2. changed element, added _1 to end
      3. changed sys_update_name to sys_dictionary_{extended table}_{new field name}
    2. imported the xml back into the extended table
    3. wrote a script to copy the data from the parent fields to the new extended fields
  5. delete the parent table custom fields
  6. with the original xml file
    1. use Textpad to modify the xml (used macros for efficientcy)
      1. changed name to the extended table name
    2. imported the xml back into the extended table
      1. now i have the original fields and the temp fields
    3. wrote a script to copy the data from the new fields to the original fields
  7. deleted the temp fields from the extended table

I did this first in a PDI so I didn't screw anything up.  Everything worked as expected.  Now I need to setup the choice lists properly so the fields will be 100% correct.

Obviously all BR's, UI Policies, field ACL's, etc must be reviewed so the new form works like the originally modified OOB form worked.  Gonna take some testing but instead of spending hours to type in the fields, twice, this method took about 20 minutes.

View solution in original post

5 REPLIES 5

kjmauriello
Mega Expert

I resolved this in the following manner:

  1. expand dictionary list view to display all columns
  2. filter the list to the custom fields I want to move
  3. export the list to xml
    1. made 2 copies of the file (temp and original)
  4. with the temp xml file
    1. use Textpad to modify the xml (used macros for efficientcy).
      1. changed name extended table name
      2. changed element, added _1 to end
      3. changed sys_update_name to sys_dictionary_{extended table}_{new field name}
    2. imported the xml back into the extended table
    3. wrote a script to copy the data from the parent fields to the new extended fields
  5. delete the parent table custom fields
  6. with the original xml file
    1. use Textpad to modify the xml (used macros for efficientcy)
      1. changed name to the extended table name
    2. imported the xml back into the extended table
      1. now i have the original fields and the temp fields
    3. wrote a script to copy the data from the new fields to the original fields
  7. deleted the temp fields from the extended table

I did this first in a PDI so I didn't screw anything up.  Everything worked as expected.  Now I need to setup the choice lists properly so the fields will be 100% correct.

Obviously all BR's, UI Policies, field ACL's, etc must be reviewed so the new form works like the originally modified OOB form worked.  Gonna take some testing but instead of spending hours to type in the fields, twice, this method took about 20 minutes.