reference1 min readApplication: Platform
RealmUtils
Methods of RealmUtils, which renumbers realms and re-stamps realm-separated records after the realm tree changes, in server scripts.
RealmUtils is the global for maintaining realms from a server script. Each realm in the tree has a CIDR range, and each record of a realm-separated table carries its realm’s CIDR. When you move a realm under a new parent, renumber it and correct its records with these methods. Realms and tenancy are explained in Multi-tenancy in the Administrator guide.
Get an instance
RealmUtils is ready to use. Pass realm records from the SystemRealm table.
let realm = Table("SystemRealm").get("<record id>");
RealmUtils.renumberDownstreamInclusive(realm);
Methods
| Method | Returns | Description | Since |
|---|---|---|---|
renumberDownstreamInclusive(realm) |
Nothing | Renumbers a realm and every realm below it, for example after the realm gets a new parent. A queued job then corrects the records of those realms. | 1.11 |
renumberDownstreamOnly(realm) |
Nothing | Renumbers only the realms below realm and keeps its own CIDR, so what users of realm see stays stable. Use it when nobody is signed in to the realms below. |
1.11 |
renumberAllRealms() |
Boolean | Renumbers every realm, then re-stamps every realm-separated record. Returns false when a table could not be updated. | 1.11 |
updateRealmCIDRsForAllTables() |
Boolean | Re-stamps every realm-separated record with its realm’s current CIDR. Returns false when a table could not be updated. It can slow the instance, so run it out of hours. | 1.11 |
updateRealmCIDRsForTable(table) |
Boolean | Re-stamps the records of one table. Returns false when the table could not be updated. | 1.11 |
clearRealmRelatedCaches() |
Nothing | Clears the cached realm ranges and the realm tenancy provider’s caches. | 1.11 |
| Method | Returns | Description | Since |
|---|---|---|---|
updateRealmCIDRsForRealmSubtrees(realmIds) |
Nothing | Corrects the records of the realms below each ID in a comma-separated list. The platform queues this after a renumber, so you rarely call it. It raises an error when a table could not be updated. | 1.11 |
numberUnnumberedRealms() |
Object | Gives a range to every realm that has none and to the realms below it, then corrects their records. Returns numbered, failed and stillUnnumbered lists of realm IDs, and recordsCorrected and succeeded flags. Administrators only. |
1.11 |
Examples
Move a realm under a new parent
let realm = Table("SystemRealm").get("<record id>");
realm.Parent("<record id>").update();
RealmUtils.renumberDownstreamInclusive(realm);