We've the following post install script in place.
We have recently updated it to check for FLS CRUD validation as Checkmarx scan suggested. Does custom settings need to have this FLS CRUD validation?
global with sharing class ConfigInstaller implements InstallHandler {
global void onInstall(InstallContext context) {
if(context.previousVersion() == null){
List<String> configFields = new List<String>{'Name','field__c','field2__c','field3__c','field4__c'};
String nameSpace = '';
List<ApexClass> prefix_Value = [SELECT NamespacePrefix FROM ApexClass WHERE NamespacePrefix='myNameSpace' LIMIT 1];
if(prefix_Value.size() > 0){
nameSpace = prefix_Value[0].NamespacePrefix + '__';
for(integer i = 0; i< configFields.size(); i++){
if(configFields[i].endsWith('__c')){
configFields[i] = nameSpace + configFields[i] ;
}
}
}
Boolean isAccessible = true;
// Obtaining the field name/token map for the Config object
Map<String,Schema.SObjectField> configMap = Schema.SObjectType.PackagedObject__c.fields.getMap();
for (String fieldToCheck : configFields){
// Check if the user has create access on the each field
if (!configMap.get(fieldToCheck).getDescribe().isCreateable()){
isAccessible = false;
}
}
if(isAccessible){
PackagedObject__c config = new PackagedObject__c();
config.Name = '_default';
config.field__c = '_default';
config.field2__c = true;
config.field3__c = true;
config.field4__c = false;
insert config;
}
}
}
Now, the installer fails and there is not much information in the error log given.
Now, am I missing something that is very obvious? What can I do before raising a case with Salesforce?
Thanks in Advance! Peace!