Changing a Table’s Parent with GlideTableParentChange - ben-vargas/servicenow-wiki GitHub Wiki

In ServiceNow, tables often inherit fields and behaviors by extending other tables. Occasionally, you may create a table under the wrong parent and need to correct this relationship without recreating the table from scratch. While no official, documented API exists for this task, the GlideTableParentChange API—an undocumented internal mechanism—can help you reassign a table’s parent.

Important: As this API is undocumented, it may not be fully supported by ServiceNow and could change or break in future releases. Exercise caution, test thoroughly, and consider contacting ServiceNow support for complex scenarios.


Overview

GlideTableParentChange allows you to set a new parent for an existing table. For example, if you initially created a custom table that should have extended task but didn’t, you can use this API to avoid manual recreation. However, altering a table’s parent can have implications for data integrity, inherited fields, and overall system behavior.


Example Usage

Script Execution Location:
You can run the script in System Definition > Scripts - Background.

Script Example:

// Variables
var table = 'u_custom_table';     // The table whose parent you want to change
var old_parent = '';              // Typically left blank unless you know the old parent
var new_parent = 'task';          // The new parent table (e.g., 'task')

// Instantiate the changer and apply the change
var changer = new GlideTableParentChange(table);
var result = changer.change(old_parent, new_parent);

gs.print('Parent change successful: ' + result);

What Happens:

  • The script attempts to update the specified table so that it now extends task.
  • The result variable indicates whether the operation was successful (true) or failed (false).

Important Considerations

  1. Use in Non-Production First:
    Always test in a development or test instance before applying changes in production. Table structure changes can have wide-reaching consequences.

  2. Data Integrity Concerns:
    While GlideTableParentChange can be run on tables with existing data, doing so may introduce unexpected results. Ideally, run it on tables that are empty or have minimal data. Consider making a backup or exporting data before running the script.

  3. Operation Not Captured in Update Sets:
    The parent change is a direct database-level alteration. It won’t appear in update sets, so carefully document your actions and inform your team.

  4. Avoid Flattened Task Extensions:
    ServiceNow discourages changing the parent of flattened tables that extend task. Attempting to do so may cause unpredictable behavior or break system functionality.

  5. Undocumented and Unsupported:
    As an undocumented API, GlideTableParentChange is not officially supported. Future platform upgrades may remove or alter this functionality. Always verify compatibility after upgrades and consider reaching out to ServiceNow support if you rely heavily on this method.


Alternatives to Consider

  1. Recreating the Table:
    For critical or complex tables, it may be safer to recreate the table under the correct parent and migrate data. Although more time-consuming, this approach ensures a clean, fully supported configuration.

  2. Consult ServiceNow Support:
    If you face challenges or uncertainties about changing a parent table, engage with ServiceNow support. They can provide guidance or suggest alternative approaches that align with platform best practices.


Additional Resources


Conclusion

GlideTableParentChange offers a powerful yet unofficial method to correct table inheritance issues. By following the recommended precautions—thorough testing, documenting changes, and considering support where needed—you can leverage this functionality effectively. However, always weigh the risks and potential future support limitations before relying on this approach for critical configuration changes.