Start tracking your progress
Trailhead Home
Trailhead Home

Package an AppExchange App

Learning Objectives

After completing this unit, you’ll be able to:

  • List the key features of a namespace.
  • Describe the benefits of using Managed - Released packages for AppExchange partners.
  • Describe the impact of installing a Managed - Beta package versus a Managed - Released package.

What’s in a Package?

A package is a container for components, like a Java JAR file or a Ruby GEM, that you use to distribute your app to customers. It contains a set of metadata with a unique namespace. A package can contain something as small as an individual component or as large as a set of related apps.

The Salesforce platform, by its very nature, encourages an agile development model in which you test incrementally and adapt your design as you go. Managed - Beta packages support this test-and-modify approach.

A Managed - Released package is used for a live product. Your customers expect a stable app that evolves over time without breaking the business processes that they’ve built on top of it. A Managed - Released package helps to ensure that you don’t break customers’ customizations and provides protection for your intellectual property.

Advantages of Managed - Released Packages

Managed - Released packages provide:

  • Intellectual property protection for Apex
  • Built-in versioning support for API accessible components
  • Ability to branch and patch a previous version
  • Ability to seamlessly push patches and major updates to subscribers
  • Unique naming of all components to ensure conflict-free installs
  • Ability to control subscriber access via licenses

Package Lifecycle in a Customer Org

Let’s look at the packaging and distribution lifecycle of your app.

  1. You publish version 1 of your app in a Managed - Released package.
  2. The customer installs the package.
  3. The customer customizes your app.
  4. You publish version 2 of your app in a Managed - Released package.
  5. The customer installs the new version of the package on top of the existing package.

We say a Managed - Released package is upgradeable because customers can install a new version over their existing version. Unmanaged packages, which are not generally used by partners, and Managed - Beta packages are not upgradeable.

The Salesforce platform is highly customizable, and your customers are likely to customize your app. They depend on a certain level of consistency in your app when you release a new version so that their customizations don’t break.

A Managed - Released package has built-in safeguards to minimize the impact of new versions. For example, you can’t remove Apex methods that have been made available to customers or objects. Check out the Components Available in Managed Packages section in the ISVforce Guide for more details.

Create a Simple App to Package Up

We’re going to break our own rules here and set up a simple app in the same org where we create a package. You can create packages only in a Partner Developer Edition (PDE) or Developer Edition org. So use the PDE org we created in the last unit.

Let’s walk through the steps of creating one of the world’s simplest apps to do some hands-on packaging. We are going to create a one-page app that displays a custom object.

  1. Go to the Setup menu.
  2. On the Lightning Platform home page, click Add App.
  3. Fill out the App Quick Start page as follows.
    Field Value
    App Trail Tracker
    Label Trail
    Plural Label Trails
    Screen of app quick start
  4. Click Create.
  5. Click Go To My App

That’s it. Let’s try out the app.

  1. Click New.
  2. For the Trail name, enter AppExchange Partner Basics.
  3. Click Save.

You’ve created a record with your app. Easy-peasy.

Packages and Namespaces

For all AppExchange apps and some OEM Embedded apps, customers install your app in an existing org with customizations. Consider the following scenario.

  • A customer has created a custom object with the API name Vendor__c.
  • Your app has a custom object with the API name Vendor__c.

Will installing your app overwrite your customer’s object? No, thank goodness. Namespaces rescue us from that fate.

To prevent conflicts, a managed package always has a namespace. A namespace is unique across Salesforce so that the installation of a managed package doesn’t conflict with customizations made by customers and other partners.

A development org can have only one namespace. You can create only one package using that namespace, but you can make updates to the package and release new versions.

How Do Namespaces Get Added to Your App?

When you create a namespace in an org, it is attached to every component within the org. If you create a package in that org, every component you add to the package comes with the namespace. The following custom object shows that (1) the org has the namespace TrailApp_Test1, and (2) the Trail object’s API name is TrailApp_Test1__Trail__c.

Screen showing Namespace Prefix and API Name using namespace

However, when you add a namespace, Salesforce doesn’t update non-Salesforce artifacts like JavaScript in which you have references to objects or fields. You must update those references yourself.

Choosing a Namespace

Because namespaces are unique, choose the namespace for your golden package org first. Your customers see the namespace that you use for the package you upload to the AppExchange. If your company name is AW Computing, you want a namespace like awc or awcomputing.

Do not use that namespace in your beta packaging org, because then it isn’t available for your golden package org.

Create a Namespace

Let’s create your namespace so that you can package up your app.

Note

Note

Trailhead doesn't support orgs with namespaces, so make sure you're practicing in a new Developer Editionor Partner Developer Edition org. If you create a namespace in the org that you use to complete Trailhead challenges, you won’t be able to earn new badges with it.

  1. From Setup, enter Package in the Quick Find box, then click Packages.
  2. In the Developer Settings section of the page, click Edit.
  3. To confirm that you want to set up a namespace, click Continue.
  4. Enter a value for Namespace Prefix. Remember, do not use a name you might want to use later. Screen for setting up namespace
  5. Click Check Availability. Repeat steps 4 and 5 until you find an available namespace.
  6. Click New.
  7. Click Review My Selections.
  8. Click Save.

Packages and Testing

What makes a Managed - Released package the best choice for selling and distributing your app also makes it a poor choice for testing. After you add certain components to a managed package, you can’t modify them. Let’s say in developing your app, you create four custom objects, Larry, Curly, Moe, and John. When you go to test your app, you decide John is unnecessary. Sorry! If the object John is in your Managed - Released package, you can’t remove it.

To get around this issue, we provide Managed - Beta packages. The components of a beta package are editable in your package org until a Managed - Released package is created.

Note

Note

You can install a beta package only in sandbox or Developer Edition orgs or test orgs created through the Environment Hub.

Create a Managed-Beta Package

Go ahead and follow these steps to create your Managed - Beta package.

  1. If you aren’t on the packages page, from Setup, enter Package in the Quick Find box, then click Packages.
  2. In the Packages section, click New.
  3. For Package Name, enter Trail App.
  4. Select the Managed checkbox to enable that option. When prompted, click OK. Screen showing creating managed package
  5. Click Save.
  6. In the Components subtab, click Add.
  7. Choose the Trail Tracker app, and click Add to Package. Notice that several dependent components were added to the package.
  8. Click Back to Package List.

Notice that by default a Managed - Beta package was created, just what we wanted.

Beta versions aren’t considered major releases, so the package version number doesn’t change.

Make Your Package Available for Installation

When you are ready to install your package in another org, you upload it.

  1. Click your package name from the list of packages.
  2. Click Upload.
  3. Fill out the Package Details section as follows.
    Field Value
    Version Name Trail App Test 1
    Description The beta package for the simple app I created working through the Build Apps as an AppExchange Partner trail.
    Screen for uploading a package
  4. Click Upload. If the upload is successful, you get a message with an installation URL. Screen for package with installation URL
  5. Copy the installation URL to use in installing your package.
  6. Log out of your org.

Install Your Package in a Test Org

  1. Paste the installation URL in your browser.
  2. On the login page that appears, enter the credentials for the Trailhead Test org that you created in unit 2.
  3. On the page that appears, click Install. Screen for installing package
  4. Click Done.
  5. Verify that your app has been installed by choosing it from the app menu. App menu with new app

Summary

You now know the basics about packages.

  • You must create packages in a Partner Developer Edition or Developer Edition org.
  • To create the package, choose a unique namespace.
  • Don’t use up your good namespace on test orgs, or you’ll be sorry.
  • Use Managed - Beta packages during the testing cycle, because it’s easy to modify their contents.
  • Use a Managed - Released package only for final testing.

Congratulations, you have all the skills to use Managed - Beta packages in your development cycle. The challenge gives you a bit more practice.

Note

Note

Remember, this module is meant for Salesforce Classic. When you launch your hands-on org, switch to Salesforce Classic to complete this challenge.

retargeting