Versions Compared

Key

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

The reparenting Reparenting of resources is currently not supported at this moment.
This is a workaround which in the GoMeddo UI and requires some additional work when done otherwise. This workaround 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 builders/flows/apexProcess Builder/ Lightning Flows/ Apex) on the resource object.Resource object

  2. Go to Custom Settings

  3. Click Manage next to System Setting

    Image Added

  4. Click New

  5. Create a custom setting value in the System Setting custom setting named: Disable ResourceType with boolean value true. This disables the resource type setting as follows:

    1. Name: Disable ResourceType

    2. Boolean Value: TRUE

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

Reparenting Resources

You may now either manually reparent your Resources. Alternatively, you can run this script with the correct

...

Resource Type and

...

Resource names

...

. This will adjust the type tree and move the resource to their new parent.

Note

The changes that are being made make to the type Resource Type tree and resource Resource tree need to match (A child of a resource Resource needs to have a type Resource Type that is a child of the resources typeparent Resource’s Resource’s Type). Normally the resource Resource and resource type Resource Type triggers validate this but because they are , 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 type of the resources that should be move>';
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

  1. Remove the

...

  1. Custom Setting, or set the boolean value to false for Disable ResourceType to reenable the

...

  1. Resource Type triggers

...

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

...

  1. Re-enable any custom logic on the resource