diff --git a/Script Includes/Reparent Table/Readme.md b/Script Includes/Reparent Table/Readme.md new file mode 100644 index 0000000000..98e804dd25 --- /dev/null +++ b/Script Includes/Reparent Table/Readme.md @@ -0,0 +1,5 @@ +# Reparent Table + +This function `reparentTable` is to reparent the existing table to the another parent. + +This `glide.rollback.blacklist.TableParentChange.change` property can restrict user to reparent the table so in script we first set it to **false** before reparenting and later on changed it to its initially value once reparenting is done. diff --git a/Script Includes/Reparent Table/script.js b/Script Includes/Reparent Table/script.js new file mode 100644 index 0000000000..f20a7e280d --- /dev/null +++ b/Script Includes/Reparent Table/script.js @@ -0,0 +1,25 @@ +function reparentTable(tableName, parentTable) { + var tableParentChangePropVal = gs.getProperty("glide.rollback.blacklist.TableParentChange.change"); + try { + gs.info(tableName + " reparent to " + parentTable); + var tableUtil = new TableUtils(tableName); + var parentTables = tableUtil.getTables(); + if (parentTables.indexOf(parentTable) != -1) { + gs.info(tableName + " is reparented to " + parentTable); + reparentingDone = true; + } else { + gs.setProperty("glide.rollback.blacklist.TableParentChange.change", false); + var tpc = new GlideTableParentChange(tableName); + reparentingDone = tpc.change(tableName, parentTable); + gs.info( + "Completed " + tableName + " reparent to " + parentTable + "with status reparentingDone = " + reparentingDone + ); + } + } catch (exception) { + gs.info("Exception thrown during reparenting: " + exception); + reparentingDone = false; + } finally { + gs.setProperty("glide.rollback.blacklist.TableParentChange.change", tableParentChangePropVal); + gs.info("Completed setting up glide.rollback.blacklist.TableParentChange.change property"); + } +}