So, we uploaded the managed package and installed it in a new org (as the clients would) but when querying from an apex class the (protected) custom setting fields it throws an exception as if the fields where empty.
1 Answer
Custom settings are initially empty on install unless you populate the settings, either by using an install script, Visualforce page in the package, global package functions, or packaged triggers.
For settings that the customer must not access or must have default values, use an install script. Otherwise, write your code to consider the possibility that settings may not be defined and be prepared to either inform the customer that configuration is necessary or choose default values.
-
Thanks, that worked. Hope it is not a security problem to write the custom setting values in code.– JoseCommented Jun 6, 2014 at 17:50
-
@Jose It's the recommended method (see Requirements Checklist: "Ensure that sensitive information is not available to all users in a customer org. This can be achieved by using Custom Settings in "Protected" mode, and creating a Visualforce page for authorized users to update information. The previously stored data should not be displayed back to the user on this page..."– sfdcfox ♦Commented Jun 6, 2014 at 17:54