0

I am system administrator. I have removed edit access of contact fields Department, Assistant.

I am executing this code:

@AuraEnabled
public static SObjectAccessDecisionWrapper updateRecords(List<SObject> records) {
    try {
        System.debug('records**: ' + records);
        SObjectAccessDecision decision = Security.stripInaccessible(AccessType.UPDATABLE, records, true);
        System.debug('decision.getRecords()**: ' + decision.getRecords());
        update decision.getRecords();
        return new SObjectAccessDecisionWrapper(decision);
    } catch (Exception e) {
        throw new ApplicationException().auraHandled(e);
    }
}

These are the logs printing:

records**: (Contact:{Department=dp1, AssistantName=pep, FirstName=pepeeaa, Phone=bs22, Id=0031n00002QwekhAAB})

decision.getRecords()**: (Contact:{Department=dp1, AssistantName=pep, FirstName=pepeeaa, Phone=bs22, Id=0031n00002QwekhAAB})

decision.getRemovedFields(); is empty. Why it is not removing the fields from the incoming records?

1 Answer 1

1

System Administrator Profile comes with Modify All Data Checked hardcoded in the profile. This overrides the field level security settings: "View All" and "Modify All" Permissions Overview

If you want to validate the FLS and Security.stripInaccessible, then try using System.runAs(User): Using the runAs Method

You must log in to answer this question.

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