Search code examples
salesforceapex-codeforce.com

Tool to aid/assist in refactoring force.com code base (renaming custom objects)


We need to rename about 15 custom objects in a force.com.

In Java, this would be a right click and about 20 minutes work, but given the number of soql queries, classes, pages, profiles etc that use these object, we're looking at a week, two weeks... or more.

So, ideally, we're looking for a refactoring tool which will help us rename this objects and resolve any interdependencies.

Force.com IDE naturally, doesn't support this. Any ideas/tools/approaches?


Solution

  • We did that with two objects and it was a royal pain, I can image 15 poses quite a challenge. As you noticed by now salesforce constructs are highly interdependent with cross, even circular references being legit. THis on the other hand makes tear-down and core modification very difficult and virtually impossible to automate.

    What you can do is following:

    1. Use sandbox for modifications, do an inventory of all constructs using affected objects. You can use Ctrl-H to search the entire workspace in IDE
    2. On sandbox, clone those 15 objects into their respective future names, they'll be empty but who cares on sandbox.
    3. Now that you have objects in place, rename all mentions in all constructs from #1 to use new objects
    4. Just to make sure try to delete old objects from sandbox, this will serve as a sanity check that you didn't miss any dependency.
    5. Off work hours delete the entire inventory of #1 from production server, leaving just bare objects with their data
    6. Now that the dependencies are gone, rename all 15 objects
    7. In one session deploy the entire modified inventory from sandbox to production, since the payload now uses new object names the tests should pass.

    I dont think it should take you more than a day for all this.