Toggle Side Panel
Forcetalks
  • Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
    • Salesforce Industry Expertise
    • Salesforce Experts by Location
  • Webinars
  • Contact Us
More options
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
      • Salesforce Industry Expertise
      • Salesforce Experts by Location
    • Webinars
    • Contact Us
    Close search

    Resolution of Managed Packages – Salesforce DX Developer Guide

    anuj1025gmail-com
    Anuj June 11, 2020
    salesforce managed packages

    Working with Salesforce DX for the resolution of managed packages:

    • First, we create an org and enable the DX version in it that is DEVHUB.
    • Enabling DEV HUB ensures that we can use Salesforce DX features in that Org.
    • We also need to install CLI for working with DX tools in the terminal window.
    • Through Salesforce DX, we can create what are called scratch org which are temporary orgs and can be used to make changes in the managed package codebase having a namespace. In this way, multiple developers can work on the same project without conflicting with one another and after the separate development, the code changes in the scratch org can be merged with the developer org having the managed package.
    • NOTE – Scratch orgs can only be made from the org having DEV HUB enabled which can be done only in those orgs where the package is not being made.

    dont miss out iconDon’t forget to check out: Salesforce DX – The X Factor For Salesforce Developers

    Following are the steps to work with the managed package codebase in the Scratch org:

    Enable DEV HUB in a Salesforce org and link namespace with the developer org having managed packages.

    The Domain Name should be defined in that Org. Following are the steps:

    1. From the App Launcher menu, select Namespace Registries.
    2. Click Link Namespace.
    3. Make sure that your browser allows pop-ups from Dev Hub organizations.
    4. Log in to the Developer Edition organization where the namespace is registered using the organization’s system administrator credentials.
    5. To view all namespaces linked to the namespace registry, select the “All Namespace Registry” view.

    Now we open the terminal window and log in to the DEV HUB enabled org using the command: sfdx force:auth:web:login -d -a DevHub

    This command opens the org and sets it to default and defines the alias name ‘DevHub’ to it.

    The next step is to set up the project on the local machine. These are the steps:

    1. First, we create a folder by the command: sfdx force:project:create -n ‘Folder Name’
      This command not only creates a folder with the specified name but also creates some files which are necessary for creating scratch orgs. (like sfdx-project.json)
    2. To retrieve the contents from developer org having the managed package, we write the command in the terminal : sfdx force:mdapi:retrieve -s -r ./mdapipkg -u <username> -p <package name>
    3. This is a zip file so we need to unzip it with the command: unzip unpackaged.zip -d. On unzipping, the code is unzipped to metadata format.
    4. Delete the unpackage.zip file: rm unpackaged.zip

    dont miss out iconCheck out another amazing blog by Anuj here: How to Setup Salesforce on VS Code – Developer Guide

    Now we move to the folder where the project is created and in the terminal, we convert the metadata format to the source format which is required for the code to be pushed in the scratch org.

    The command is: sfdx force:mdapi:convert -r mdapipkg/

    •  Now we create a new SCRATCH Org the command: sfdx force:org:create -s -f config/project-scratch-def.json -a <Alias Name>
    • We can open the newly created Scratch org by the command: sfdx force:org:open
    •  Before moving the code to the scratch org, we specify the namespace of the managed package in the sfdx-project.json file
    •  After specifying the namespace, we push the codebase to the scratch org using the command: sfdx force:source:push
    •  All the code base of the developer org has now been moved to the scratch org along with the namespace.
    • Now we can make the changes to the scratch org.
    • After making all the changes, now we move the code from the scratch org to the local machine using the command: sfdx force:source:pull
      The code changes are moved to the local machine in the same place from where they were pushed (i.e. the ‘force-app’ folder) .
    • Now we convert it back to the metadata format using the command: sfdx force:source:convert -r force-app -d deploy
      -r denotes the folder directory where the code to be converted is present.
      -d denotes the folder where the converted code is saved.
    • Now the last step is to deploy the code to the main org for which the command is: sfdx force:mdapi:deploy -d deploy -u ‘username of the dev org’
    • To generate a password for a Scratch Org, we use the command: sfdx force:user:password:generate -u ‘Alias Name’
    • By default, scratch orgs are active only for a period of 7 days, but we can extend it to a maximum of 30 days.

    Reference: salesforce.stackexchange

    Categories: Others
    Tags: App Launcher, Developer Edition, Developer Org, Domain Name, DX Tools, DX Version, Local Machine, Managed packages, Metadata, Package Codebase, Salesforce, Salesforce DX, Salesforce Org, SCRATCH Org

    Get listed your company

    Have an innovative Salesforce solution that delivers faster, smarter results?
    Join the Marketplace

    [adinserter block=”16″]

    best salesforce consultants
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    Forcetalks

    © 2026 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.