AddThis Feed Button

Recent Items

Tags: metadata

I was coding up an Apex Trigger today and ran into a bit of a problem. I was coding on my Sandbox system (as one should), but needed to access some custom fields that I had created on the Campaign object. Unfortunately, I had created these fields in my Production system and were not available in my Sandbox.

Yes, I could refresh my Sandbox, which would result in a perfect match with Production. However, that also clears out all the data and I hate having to reload Contacts and various objects just to be able to use the system productively.

So, I had a problem. My code was in Sandbox, my config was in Production. What to do?

Enter the new Metadata Migration Tool! (aka Force.com Migration Tool)

Just out with the Summer ’08 release is this new user-unfriendly, but perfectly useful tool. Unfriendly because it uses Ant scripts, with XML configuration files much like running Data Loader in batch mode. Perfectly useful because it was exactly what I needed!

In no time I managed to configure the system to extract my standard Campaign object and a matching Page Layout from Production, then deploy it to the Sandbox. Voila! My configuration was copied across without having to reload the whole Sandbox.

Some tricks I figured out:

  • In the build.properties file, I changed sf.username to sf.usernamePRD and added sf.usernameSandbox. That way, I can refer to different environment within the build.xml file. Same for sf.serverurl.
  • Layout names are prefixed with the object name. To retrieve my Page Layout called “Webinar Layout” that’s on my Campaign object, I had to put this in my package.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Campaign</members>
        <name>CustomObject</name>
    </types>
    <types>
        <members>Campaign-Webinar Layout</members>
        <name>Layout</name>
    </types>
<version>11.0</version>
</Package>

The Bottom Line

  • The Metadata Migration Tool is very useful
  • I wish it had a better interface, or was integrated into the Eclipse development tool

One Response to “Meta-impressed with the new Metadata Migration Tool”

  1. Jesse Lorenz Says:

    John, for one-off configuration migrations, copying and pasting the metadata components via the Force.com IDE is likely your best bet. The Metadata Migration Tool is really more useful for repetitive/automated deployments. Definitely digging the blog – especially the skin!