1

What can be the possible cause of error Unable to retrieve feature parameter Display. No results found.?

The line which fails is the following:

System.FeatureManagement.checkPackageIntegerValue('Display')
1

There are two possible causes of this error.

  1. You reference this in the code but didn't include the Feature Parameter in the package version.
  2. You reference this in the org where you develop the package

To resolve the error for the first case, the referenced feature parameter should be added to package version and new package version should be uploaded and installed.

To resolve the second error, you need to develop some mock to mock the value of Feature Parameter like this:

public with sharing class Feature {
    public enum Display {Label, ApiName}
    public interface DisplayProvider{
        Display getDisplay();
    }
    @testVisible static DisplayProvider provider = new FeatureManagementProvider();
    public static DisplayProvider getProvider() {
        return Type.forName('MockFeatureProvider') != null ? (DisplayProvider) Type.forName('MockFeatureProvider').newInstance() : provider;
    }
    public class FeatureManagementProvider implements DisplayProvider{
        public Display getDisplay() {
            return Display.values()[System.FeatureManagement.checkPackageIntegerValue('Display')];
        }
    }
    public static Display getDisplay() {
        return getProvider().getDisplay();
    }
}

Also on development org create a class MockFeatureProvider

public with sharing class MockFeatureProvider implements Feature.DisplayProvider {
    public Feature.Display getDisplay() {
        return Feature.Display.values()[1];
    }
}

This class should not be included in the package. It is possible to include some custom settings to derive the value from the custom setting or just modify the MockFeatureProvider class to change the value returned.

In the code where you need to check the value of the Feature Parameter, call Feature.getDisplay(), this method would return the mocked value on development org or actual value on subscriber org where no mock is present.

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.