I am trying to retrieve the source code using mdapi/source commands from a pkgOrg which has 1Gen Managed package. But, namespace is appending in the salesforce components.

I have known that namespace will be appended while package is getting created.

Anyone know how can we retrieve the source code without namespace from PkgOrg.

Or is there any tool that can find the hardcoded namespace in the retrieved folder and remove everything?

  • So, I'm not able to replicate your problem. I created a new org, created a new custom object and new apex classes, registered a namespace, created a managed package, added the components, uploaded/released the package, and when I try to retrieve from the org, it retrieves without the namespace. This is also the same behavior I'm getting working on a 1GP at work as well; the source never retrieves with the namespace from any scratch org, either. Can you elaborate on how you're doing things so we can try to replicate it?
    – sfdcfox
    Commented Aug 10, 2021 at 1:40
  • Side note: make sure you're actually logged in to the packaging org and not an org where it's installed. From there, you would get the namespace.
    – sfdcfox
    Commented Aug 10, 2021 at 1:51

1 Answer 1


The Metadata API does not alter the presence or absence of the namespace during retrieval of metadata. It gives you what is present in the org.

It's fairly common for 1GP package source to contain references to its own namespace, particularly if the package has either been developed directly in the packaging org or in namespaced scratch orgs.

CumulusCI's retrieve_packaged task (disclaimer: I am on the CumulusCI team) can retrieve the packaged source and remove all references to the namespace via the --namespace-strip option. However, it's not really doing anything different than what you'd do with any tool by running the retrieval, doing a global search and replace for the MyNS__ string, and renaming any files starting with MyNS__.

  • I assume it also handles the Apex class prefixing like "namespace."? Note that Illuminated Cloud IDE can also do this during retrieve.
    – Phil W
    Commented Aug 10, 2021 at 6:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .