0

we have an unlocked package (mypkg) that has a folder with some metadata no longer in use by the org and we just want to remove it. Here are my steps:

I went to 'mypg' installed package detail in the UI under 'installed packages' and then clicked 'view components'

I then removed the metadata that I was planning to delete in the new package.

I then went into my package git source and deleted the folder and committed the changes.

I created a new package version:

sfdx force:package:version:create --package mypkg--installationkeybypass --wait 20

After that I installed it:

sfdx force:package:install --package mypg@016.0-16 -u sandbox3-org --publishwait 20 --wait 10 --apexcompile package --upgradetype Delete

Now when I go to the sandbox, I still see the metadata (classes and custom objects). Why is that? There are no references to it. Documentation states that --upgradetype Delete should have deleted that metadata.

0

Unlocked package is created based on Source in your sfdx project. It doesn't matter if you delete some metadata in the org, unless you pull this changes, so they're reflected in your project.

Then you can create new version and when you install it you'll see changes.

So you can either

  1. Go to you force-app/main/default/objects and delete data that you want (assuming you are using default project structure) and then create a new version

  2. Or you can create Scratch Org push there your currect source, manually delete required Metadata data, then do force:source:pull and after that create a new version.

Both options are valid depending on your preference for changes things directly in the project or on org.

Regarding the steps you took. You just removed components from the package for the particular org you were using, but haven't changed package itself.

3
  • @ytik my apologies in not being clear but I did delete the folder in the unlocked package source. I edited my answer above to be more explicit. – kratos Apr 8 at 12:13
  • ok, I got the issue. It documentation it states that --Delete doesn't remove SObjets and Ccustom fields, even if they don't have dependencies. or to delete all removed components, except for custom objects and custom fields, that don't have dependencies (Delete). – ytiq Apr 8 at 13:47
  • 1
    I think the simplest way then is to create Destructive changes via mdapi and push to target org, if you need assistance with that I can provide more details in the answer – ytiq Apr 8 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.