I have an Account list and I want to update it.
I want to testing object and field level security enforcement but I'm wondering what I have to test :
1 - if Account object is updatable ? (if it's possible)
2 - if the fields in my select query is updatable ?
3 - only if the Account Name is updatable ?
Here the code for these three propositions :
List<Account> acc = [SELECT Id, Name, BillingStreet FROM Account];
...
// 1 : I don't know if it's possible to test if an object is updatable ?
// 2 : test all the fields in the select query
if (!Schema.sObjectType.Account.fields.Name.isUpdateable() && !Schema.sObjectType.Account.fields.BillingStreet.isUpdateable() ){
update acc;
}
// 3 : test only the Name
if (!Schema.sObjectType.Account.fields.Name.isUpdateable()){
update acc;
}