Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Reparenting Resources

GoMeddo let’s you reparent Resources, as long as the new parent should have the same Resource Type as the old parent. This can only be done through the Salesforce UI. GoMeddo will make sure that the Materialised Path is updated accordingly. If you reparent to a different time zone, you will also need to make sure to update the timezone of the Resource you moved.

Reparenting Resource Types

Note

Reparenting of Resource Types is currently not supported in the GoMeddo UI and requires some additional work when done otherwise. Ideally it would be best to export existing Reservations, . Should you need to change the Resource Type structure, we suggest:

  1. exporting existing Reservations

  2. delete the entire Resources and Resource Types tree

,
  1. rebuild it from scratch

and then
  1. import the Reservations to the right parent.

However ever if for any reason that is not possible, you can try this workaround. This needs to be carefully checked before executed, we don’t offer any support or guarantees that this will work.

Before Reparenting

  1. Disable any custom logic (Process Builder/ Lightning Flows/ Apex) on the Resource object

  2. Go to Custom Settings

  3. Click Manage next to System Setting

    Image Removed

  4. Click New

  5. Create a setting as follows:

    1. Name: Disable ResourceType

    2. Boolean Value: TRUE

  6. This will disable the Resource Type trigger in GoMeddo.

Reparenting Resource Types

You may now run this script with the correct Resource Type and Resource names. This will adjust the Resource Type tree and move the Resources to their new parent.

Note

The changes that are being made make to the Resource Type tree and Resource tree need to match (A child of a Resource needs to have a Resource Type that is a child of the parent Resource’s Resource’s Type). Normally the Resource and Resource Type triggers validate this, but as those have been disabled during this process, you could create an invalid configuration. Reenabling the trigger after this process will not correct any incorrect parent relationships or other errors introduced.

Code Block
String moveType = '<The name of the Resource Type that should be moved. (This will also move the Resource Type's Resources)>';
String newParentName = '<The new parent Resource for these Resources>';
B25__Resource_Type__c toMoveType = [SELECT Id, Parent__c FROM B25__Resource_Type__c WHERE Name = :moveType];
B25__Resource__c newParent = [SELECT Id, B25__Resource_Type__c FROM B25__Resource__c WHERE Name = :newParentName];
Id oldParentType = newParent.B25__Resource_Type__c;

// Set the type of the new parent so that it has the type that the records we want to move have as parent right now
newParent.B25__Resource_Type__c = toMoveType.Parent__c;
Database.update(newParent);

// Move the resource type tree
toMoveType.Parent__c = oldParentType;
Database.update(toMoveType);

// Reparent the resources
List<B25__Resource__c> resourcesToMove = [SELECT Id FROM B25__Resource__c WHERE B25__Resource_Type__r.Name = :moveType];
for (B25__Resource__c resource : resourcesToMove) {
    resource.Parent__c = newParent.Id;
}
Database.update(resourcesToMove);

// Set the type back to the old value
newParent.B25__Resource_Type__c = oldParentType;
Database.update(newParent);

After Reparenting

...

Remove the Custom Setting, or set the boolean value to false for Disable ResourceType to reenable the Resource Type triggers

...

This process might have broken the materialised path in the org run, so please run Fix Materialized Path

...