Skip to content

Commit 636f08a

Browse files
Reparent Table (ServiceNowDevProgram#707)
1 parent 2b8274f commit 636f08a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Reparent Table
2+
3+
This function `reparentTable` is to reparent the existing table to the another parent.
4+
5+
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.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function reparentTable(tableName, parentTable) {
2+
var tableParentChangePropVal = gs.getProperty("glide.rollback.blacklist.TableParentChange.change");
3+
try {
4+
gs.info(tableName + " reparent to " + parentTable);
5+
var tableUtil = new TableUtils(tableName);
6+
var parentTables = tableUtil.getTables();
7+
if (parentTables.indexOf(parentTable) != -1) {
8+
gs.info(tableName + " is reparented to " + parentTable);
9+
reparentingDone = true;
10+
} else {
11+
gs.setProperty("glide.rollback.blacklist.TableParentChange.change", false);
12+
var tpc = new GlideTableParentChange(tableName);
13+
reparentingDone = tpc.change(tableName, parentTable);
14+
gs.info(
15+
"Completed " + tableName + " reparent to " + parentTable + "with status reparentingDone = " + reparentingDone
16+
);
17+
}
18+
} catch (exception) {
19+
gs.info("Exception thrown during reparenting: " + exception);
20+
reparentingDone = false;
21+
} finally {
22+
gs.setProperty("glide.rollback.blacklist.TableParentChange.change", tableParentChangePropVal);
23+
gs.info("Completed setting up glide.rollback.blacklist.TableParentChange.change property");
24+
}
25+
}

0 commit comments

Comments
 (0)