The following are methods for SObjectAccessDecision.
public Set<Integer> getModifiedIndexes()
Type: Set<Integer>
A set of unsigned integers that represent the row indexes of the modified sObjects.
In this example, the user doesn’t have permission to update the AnnualRevenue field of an Account.
List<Account> accounts = new List<Account>{ new Account(Name='Account1', AnnualRevenue=1000), new Account(Name='Account2') }; // Strip fields that are not updatable SObjectAccessDecision decision = Security.stripInaccessible( AccessType.UPDATABLE, accounts); // Print stripped records for (SObject strippedAccount : decision.getRecords()) { System.debug(strippedAccount); } // Print modified indexes System.debug(decision.getModifiedIndexes());
The stripInaccessible method performs field-level access check for the source records in the context of the current user’s operation. The getRecords() method returns the new records that contain only the fields that the current user has access to.
public List<SObject> getRecords()
Type: List<SObject>
Even if the result list contains only one sObject, the return type is still a list (of size one).
In this example, the user doesn’t have permission to update the AnnualRevenue field of an Account.
List<Account> accounts = new List<Account>{ new Account(Name='Account1', AnnualRevenue=1000), new Account(Name='Account2') }; // Strip fields that are not updatable SObjectAccessDecision decision = Security.stripInaccessible( AccessType.UPDATABLE, accounts); // Print stripped records for (SObject strippedAccount : decision.getRecords()) { System.debug(strippedAccount); }
public Map<String,Set<String>> getRemovedFields()
Type: Map<String,Set<String>>
In this example, the user doesn’t have permission to update the AnnualRevenue field of an Account.
List<Account> accounts = new List<Account>{ new Account(Name='Account1', AnnualRevenue=1000), new Account(Name='Account2') }; // Strip fields that are not updatable SObjectAccessDecision decision = Security.stripInaccessible( AccessType.UPDATABLE, accounts); // Print stripped records for (SObject strippedAccount : decision.getRecords()) { System.debug(strippedAccount); } // Print removed fields System.debug(decision.getRemovedFields());