Sunday 13 October 2019

Unlocked Packages | Modular Application Development Using Unlocked Packages | 2GP

Salesforce offers different types of packages (unmanaged, managed and Unlocked). Unlocked packages are especially suited for internal business apps and allowed you to do modular application development. Unlocked package is the right package type for most use cases, Unless you plan to distribute an app on AppExchange. You can use unlocked packages to organize your existing metadata, package an app, extend an app that you’ve purchased from AppExchange, or package new metadata.

Unlocked packages help you add, edit, and remove metadata in your org in a trackable way. You can install unlocked package to multiple orgs, and upgrade your Salesforce apps easier and faster. Metadata in unlocked packages can be modified in a production org ( You can do in case of emergency but not recommended).

Unlocked packages follow a source-driven development model. The source of truth of the metadata contained within the package is your version control system, not what’s in an org. This model brings with it all the advantages of modern source-driven development models.

We did one session on Unlocked Package in ApexHours With Mohith. Here is some highlight of that session.

What is Package ?


Packaging allows you to group various Salesforce Components (Apps, Tabs, Objects, Layouts, Workflows, Approval Process Flows, visualforce, apex, lightning components, profiles, permission sets and other metadata) for distribution or deployment. A package can also be defined as a container and allows for deployment of the components across various Salesforce organizations. Salesforce Set up UI and Salesforce CLI allows for creation of these. Package Creation yields a URL that allows it to install in various orgs

Difference Between Unmanaged package , Manage and Unlocked Package.


Unmanaged Package Managed Package Unlocked Package
Not upgradable  Upgradable and has namespace Upgradable and one can namespace them or choose not to
Metadata elements are not IP Protected Metadata elements are IP Protected Metadata elements are not locked and can be changed by system admins
Can we created in Salesforce UI Can be created in salesforce UI and distributed via appexchange Requires Salesforce CLI to generate them 
Unmanaged package containers automatically pull dependency Components are locked and one cannot modify them directly in production or sandbox Allows you to build your applications in a modular way

Allows for creation of extension packages Easier to manage when codebase is modularized

Modular Application Development Concepts


Break Your one monolithic app to multiple packages defining dependency between them. Unlock packages allow you to do them.

Building Unlocked packages using Salesforce CLI


Please check this recording for step by step process. Thank you so much Mohith for a great session in ApexHours. Here is agenda of session.
  1. Introduction To Salesforce Packaging
  2. Differentiate between unmanaged packages , managed packaged and unlocked packages
  3. Modular Application Development Concepts
  4. Building unlocked packages using salesforce cli
  5. Creating Dependency between packages
  6. Publishing and Installing Unlocked packages

Here is useful Salesforce DX command to create unlocked package. If you are new to SalesforceDX please check this recording.
  • One can create a package using below  
    sfdx force:package:create --name <name> --description <description> --packagetype Unlocked --path force-app --nonamespace --targetdevhubusername <Devhubalias>
  • Create a package version as below 
    sfdx force:package:version:create -p <packagename> -d force-app --wait 10 -v <Devhubalias>
  • Installation can also be done via the Salesforce CLI  
    sfdx force:package:install --wait 10 --publishwait 10 --package <packagename>@1.0.0-1 -r -u <alias>
  • By Default a BETA package is generated . We can promote a package using below 
    sfdx force:package:version:promote -p <packagename>@1.0.0-1 -v <DevHubalias>

References :-

No comments:

Post a Comment