function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ryan Avent 14Ryan Avent 14 

mdapi:deploy errors for new package (first gen)

Hello im deploying a brand new package to our existing packaging org and am hitting a tone of errors, im following the instructions (https://developer.salesforce.com/docs/atlas.en-us.packagingGuide.meta/packagingGuide/sfdx_dev_build_man_pack_deploy.htm) but the project is failing due to 'object does not exist' or 'varible does not exist' but all these are part of the meta im trying to deploy... 

 

im running the command :

sfdx force:mdapi:deploy --deploydir "my deploydir"  --targetusername me@example.com

 

The only thing i can think of is that this package has a new namespace, can a packaging org only handle one namespace/ do i need seperate orgs (i have a devhub for the namespace). 

Casey ScottCasey Scott
Hello,

It seems like you're encountering deployment issues while trying to deploy a new package using Salesforce's Metadata API (MDAPI) and the SFDX CLI. Deployment errors can stem from various issues, and it's good that you're seeking assistance. Let's break down the possible reasons for the errors you're facing:

Namespace Conflicts: You mentioned that the new package has a new namespace. Salesforce allows multiple managed packages in a single packaging org, each with its own namespace. However, if you're using a namespaced package, make sure that your code and metadata references are updated to reflect the new namespace. If you're referencing objects or variables using the old namespace, it will indeed result in errors.

Metadata Dependencies: If your new package depends on metadata that's not properly defined or is missing, you might encounter "object does not exist" or "variable does not exist" errors. Ensure that all the referenced metadata is properly included in your deployment package.

Metadata Order: Sometimes, the order in which metadata components are deployed matters. If there are interdependencies between components, you might need to adjust the deployment order or use package.xml to specify dependencies explicitly.

Version Compatibility: Make sure that your metadata components are compatible with the target org's Salesforce version. If you're using features that are not available in the target org's version, deployment might fail.

Metadata API Limitations: The Metadata API might have limitations or specific requirements for certain metadata types. Review the documentation for any metadata types you're deploying to ensure you're following the correct structure.

Deployment Settings: Double-check the deployment settings and flags you're using with the force:mdapi:deploy command. Ensure that you're deploying to the correct org (--targetusername) and using the correct deployment directory (--deploydir).

Namespace Prefix: If your package has a namespace, you need to include the namespace prefix in your references to objects and fields within your code. The format is typically Namespace__Object__c.

Dev Hub Org: You mentioned having a Dev Hub org. This is the right approach for managing and packaging multiple namespaces. Each namespace can have its own package, and the Dev Hub org helps you manage the packaging process.

Error Details: When the deployment fails, the command-line output usually provides more detailed error messages. These messages can give you insights into which components are causing issues and why. (https://www.mayoclinicpatientportals.com/)