trailhead

Package Custom Metadata Types

Learning Objectives

After completing this unit, you’ll be able to:
  • Package your custom metadata types.
  • Package your types’ associated records.
  • Upload your package.
  • Install your package in a subscriber org.
  • Upgrade your package.

Package Custom Metadata Types

When you’re ready to package up your custom metadata types and records, you can choose your own adventure. Managed packages, unmanaged packages, and managed package extensions are all compatible with custom metadata types. And change sets let you deploy your types and records from a sandbox.

You’re itching to get your Threat Tier type out to your other orgs, so let’s do it. From Setup, search for Packages and then click a package name (or create a package if you haven’t yet). You can use either a managed or an unmanaged package.
Note

Note

You can have only one managed package per Developer Edition org. To create a managed package, your org must be namespaced. If you aren’t familiar with namespaces or don’t want to add a namespace, use an unmanaged package.

Next, add your custom metadata type to the package.

  1. Click Add.
  2. For the component type, select Custom Metadata Type.
  3. Select Threat Tier.
  4. Click Add to Package.

Easy! Notice that your custom metadata type and its fields were added to the package, but your records are missing. Let’s take care of that next.

Package Custom Metadata Records

The process for adding custom metadata records to a package is almost the same as it is for packaging types. The only difference is that instead of selecting a standard option from the list of component types, you select your specific type. Let’s give it a try, starting from the package detail page.

  1. Click Add.
  2. For the component type, select Threat Tier.
  3. Select all your custom metadata records.
  4. Click Add to Package.

The package detail page displays all the components you added to the package, including your custom metadata types and records.
You don’t have to add a custom metadata type’s records to the package. However, if you add records of that type to a package, your type is added to that package automatically.

Upload Packages

After you’ve added all your custom metadata types, records, and any other components your app needs, you’re ready to rock and roll. Uploading a package that contains custom metadata types and records isn’t any different from uploading other types of packages.

Click Upload on the package detail page to kick off the process. Set the version name to Spring 2016, and leave the Version Number as is.

Typically if you’re using a managed package, you want your first release to be beta. But we’re all about diving in, so let’s go straight for the big time. Select Managed - Released for the release type. If you’re using an unmanaged package, don’t worry about this part.

For more complex packages, you’ll probably have to spend some time fiddling with the other options on this page. But for now, just click Upload and wait for the process to complete.

Install Packages

When your upload is finished, you’ll receive an email with an installation link for your package. If you have another Developer Edition org, you can see for yourself the results of your fearless adventure into the world of meta. If not, you just have to take our word for it.

Make sure that you’re logged out of the org where you developed the package. Follow the link in the email, and log in to your alternate account. When prompted, install the app for admins only. When the installation completes, your app appears on the Installed Packages page.

But how do we know whether we successfully completed our journey?

In the Quick Find box, search for Custom Metadata Types. If all went as planned, you see your Threat Tier custom metadata type. That’s all well and good, but what you’re really interested in is whether your records migrated over.

Click Manage Records to see the magic for yourself.

If installed correctly, all the custom metadata records are visible in the subscriber org's custom metadata view.

Looks like the gang’s all here! You’ve successfully moved your app configuration records from one org to another in just a few easy steps.

Upgrade Packages with Custom Metadata Types

Of course, our adventure isn’t over yet. App development is rarely a one-and-done process. Down the line, you’ll want to make improvements and fix your app.

Upgrading managed packages is where our earlier discussion about field manageability is especially important.

For example, we made our Account Tier field upgradeable. So as the package developer, you can change the Account Tier field and the values of this field on records in future iterations of the app. On the other hand, your subscriber orgs can’t make changes. They can create Threat Tier records, but not edit existing values.

Vacation is a subscriber editable field, so the subscriber org can change the field based on its own needs. Subscriber editable also means that you can’t overwrite your subscriber’s values through a package upgrade.

If you created a managed package, you can deploy an upgrade to see how this works. In your development org, make some changes to both the Account Tier and Vacation fields. Using the same process as before, upload your package and reinstall it in your subscriber org using the email link. Check the fields and records on the upgraded package. You can see the changes you made to the Account Tier field, but the Vacation field looks the same as it did before the upgrade.

You’ve made it to the last leg of the journey. Only one question remains: What do you do with all your existing app configurations now that you’ve found a better way?

retargeting