2

Please hear me out before marking this question as a duplicate or downvote.

We are trying to migrate from Unpackage monolith to Unlock packages. For this, We have decided to split into 3 packages.

  1. Object-Base package (contains all the objects)
  2. Core (contains all the common utilities, depends on Object-Base package)
  3. Product Package. (divided by business teams Product package A, product package B etc all depends on package 1 and 2)

I am getting an error while deploying my metadata to fresh scratch org You reached the maximum number of allowed active filtered lookups (10) on Product. (Yes we asked Salesforce Support to increase the limit to 15) So we decided to use Org Shape (though it's currently in Beta) and I was able to push my objects to Scratch orgs.

But while creating the package version it was throwing me the same error You reached the maximum number of allowed active filtered lookups (5) on Product. Apparently, Sfdx does not consider Org Shape while creating Unlock packages. We used the Org Dependent(it's in beta) package for the Object-Base package to overcome this situation.

This worked as expected because Org dependent packages validate your metadata at run time. While creating Core package with Object-Base package dependency it still throwing me the same error. You reached the maximum number of allowed active filtered lookups (5) on Product.

One approach I am thinking of is to make the Lookup filter false while creating packages and update the metadata through PostInstall script (just like we use for Managed package) or mdapi commands to update the fields Lookup filter from false to true? Or Is there any other workaround for my situation? Unfortunately, PostInstall script doesn't work for Unlock packages and running Apex code through Anonymous Window to update Metadata also doesn't work as it throws Cannot modify managed object: entity=NamedFilter, component=null, state=SECOND_GEN_INSTALLED_EDITABLE - filters (CANNOT_MODIFY_MANAGED_OBJECT)

I don't want to use all my packages to be OrgDependent package as it's still in development and not sure if it will see any Daylight.

1
  • 1
    I don't see an option to add additional lookup filters, so Org Dependent is your only solution, as far as I can tell.
    – sfdcfox
    Jun 11, 2021 at 15:56

1 Answer 1

0

As a workaround you could make the lookup filters which exceed the limit as optional and then introduce a manual action after deploying the package in which the Lookup filters will be checked as required. That's the easiest workaround I can think of as we still don't have any possibility to adjust scratch orgs in regards of lookup filter limits.

3
  • Thanks, I tried that as well but we cannot update the Metadata via Metadata API for Unlock packages. The only solution seems to use the Org-Dependent package. Nov 26, 2021 at 10:36
  • What I mean with manual action is doing it as a post deployment manual action via the UI by going to the field and checking the required checkbox
    – Asadiya
    Nov 26, 2021 at 15:00
  • Ok. Actually, I cannot use it as we have a weekly release and every time package sees any changes it changes back to what the package has. plus we have total of 6 different orgs and it is simply impossible to change it manually for all 6 every week. But glad you found some workaround. Nov 29, 2021 at 11:22

You must log in to answer this question.

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