2

Could you kindly let me know if its possible to populate the protected custom setting data after installing the managed package. Custom setting is also part of our managed package.

So we would like to also populate the data on that custom setting, by using InstallHandler , but users should not see the data. only the managed package code can access the data.

Is it possible?

3
  • We usually resolve this by adding a setup/configuration page and have a button asking user to press to trigger the setting of custom settings. This is not a bad user experience. However, not sure whether there is an automatic way though
    – Lance Shi
    Dec 21, 2016 at 23:23
  • But how will you populate the data to that custom setting? We are planning to save username password in custom setting for REST api. So I dont want users to see the data, if they have view set up config
    – PSH
    Dec 21, 2016 at 23:26
  • Answered that. It is pretty much how to populate data manually.
    – Lance Shi
    Dec 21, 2016 at 23:39

2 Answers 2

0

We usually resolve this by adding a setup/configuration page and have a button asking user to press to trigger the setting of custom settings. This is not a bad user experience.

In answering to how to populate data to custom setting, it is a VF page inside your managed package and the custom setting in your managed package as well. So you just do it as you normally do. Something like below:

CustomSetting__c vcSetting = CustomSetting__c.getOrgDefaults();
vcSetting.AField__c = 'Test';
vcSetting.BField__c = 'Abc';

update vcSetting;
5
  • I din know that we can actually update the protected custom setting from a vf page.. wow if it works
    – PSH
    Dec 22, 2016 at 0:02
  • @user3303348 I haven't tried it myself this time. But I do believe we have tried similar things before and it worked for us. And according to this post here: salesforce.stackexchange.com/questions/38882/… . It definitely should work.
    – Lance Shi
    Dec 22, 2016 at 0:07
  • You rock sir!!!
    – PSH
    Dec 22, 2016 at 0:10
  • I shall work on it and paste the code, if it works, so that others may take the advantage of this.
    – PSH
    Dec 22, 2016 at 0:10
  • @user3303348 Schweet! Glad it works for you.
    – Lance Shi
    Dec 22, 2016 at 0:12
1

Your InstallHandler must be global, but it can call methods on classes that are merely public. If you create the data in those classes, it will remain hidden.

0

You must log in to answer this question.

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