0

Looks like Post Install script doesn't update Feature Parameters values. I tried to use Without Sharing context and enqueueing a queueable job but nothing helps.

public inherited sharing class InstallHandler implements System.InstallHandler {
    public void onInstall(InstallContext context) {
        new SecurityTrampoline().collect();
    }

    public without sharing class SecurityTrampoline {
        public void collect() {
            FeatureManagement.setPackageIntegerValue('IntegerMetric', 404);
            System.enqueueJob(new SaveIntegerMetrics());
        }
    }

    public without sharing class SaveIntegerMetrics implements Queueable, Database.AllowsCallouts{
        public void execute(System.QueueableContext c) {
            FeatureManagement.setPackageIntegerValue('IntegerMetric', 213);
        }
    }
}

Also I have defined the Subscriber-to-LMO Integer Feature Parameter

<?xml version="1.0" encoding="UTF-8"?>
<FeatureParameterInteger xmlns="http://soap.sforce.com/2006/04/metadata">
    <dataflowDirection>SubscriberToLmo</dataflowDirection>
    <masterLabel>IntegerMetric</masterLabel>
    <value>0</value>
</FeatureParameterInteger>

1 Answer 1

0

Looks like the reason was quite stupid mistake, I missed the --postinstallscript parameter when creating package version.

When I changed from

sfdx force:package:version:create  -d force-app -x -w 60

to

sfdx force:package:version:create  -d force-app -x -w 60  --postinstallscript InstallHandler

it started working

You must log in to answer this question.

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