function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MaximeMaxime 

FLS error on custom settings

Hi,

I have an error on the source scanner : FLS create/update
 
public with sharing class Heeet_ApikeyController {

    public app_settings__c settings {get;set;}

    public Heeet_ApikeyController() {
        settings = app_settings__c.getOrgDefaults();
    }

    public void saveSettings() {
        upsert settings;
    }

}

I cant find any documentation about FLS on custom settings. This page is only accessible by admin (package setting page)
VinayVinay (Salesforce Developers) 
Hi Maxime,

There is no field-level security for custom settings.  Check if there is 'Customize Application' permission is enabled.

https://salesforce.stackexchange.com/questions/114081/how-do-you-configure-field-level-security-for-custom-settings-in-managed-package

Thanks,
MaximeMaxime
Something like this ?
 
PermissionSetAssignment permission = [SELECT Id, PermissionSet.PermissionsCustomizeApplication FROM PermissionSetAssignment WHERE AssigneeId = :UserInfo.getUserId() AND PermissionSet.PermissionsCustomizeApplication = true];

if(permission.PermissionSet.PermissionsCustomizeApplication == true) {
      upsert settings;
}

 
VinayVinay (Salesforce Developers) 
You can try above snippet however I am not 100% sure and hope that works with your use case.

Thanks,
KIRAN HEBBARKIRAN HEBBAR
We are also facing a same issue - CRUD/FLS violation is detected in a security view in an apex class which updates custom setting field. How do we handle this? Can we just add this in false promise report?