0

I want to move some fields and some piece of functionality which we have developed but don't want to release yet to package extension.

But I have some both either with deployment to scratch org or with building a package.

I have two folders: base and extension. Base folder contains the base package and extension contains the metadata of the package extension.

If I have the file both in the base and extension folder like this

base/objects/CustomMetadata__mdt/CustomMetadata__mdt.object extension/objects/CustomMetadata__mdt/CustomMetadata__mdt.object 

extension package installation fails with an error

  1. Cannot add component of type:CustomObject CustomMetadata__mdt subjectId to another package because it is an installed component., Details: package.xml: Cannot add component of type:CustomObject CustomMetadata__mdt subjectId to another package because it is an installed component.

If I have only file in the base folder,

base/objects/CustomMetadata__mdt/CustomMetadata__mdt.object 

I receive an error when I try push the both codebase to my scratch org

{ "fullName": "CustomMetadata__mdt", "type": "CustomObject", "state": "Failed", "error": "Must specify a non-empty label for the CustomObject", "problemType": "Error", "filePath": "/CustomMetadata__mdt/CustomMetadata__mdt.object-meta.xml" }, 

How can I make it to work both for the deployment of unpackaged metadata to a scratch org and installation of package extension when built?

1 Answer 1

0

I ended up with having two folders: unpackaged and packaged.

In the first folder I keep the source of truth for the code and I introduce the changes here and keep there two files

base/objects/CustomMetadata__mdt/CustomMetadata__mdt.object extension/objects/CustomMetadata__mdt/CustomMetadata__mdt.object 

.

When I build the package, I copy the sources from unpackaged to packaged, change c to $namespace where needed and remove the file

extension/objects/CustomMetadata__mdt/CustomMetadata__mdt.object 

so that 2GMP extension is built with only fields or validation but without introducing a new copy of the custom metadata object itself.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.