Q: 7
A developer must write an Apex method that will be called from a Lightning component. The method
may delete an Account stored in the accountRec variable.
Which method should a developer use to ensure only users that should be able to delete Accounts
can successfully perform deletions?
Options
Discussion
I thought A makes sense if you're calling isDeletable on the record variable directly.
C doesn't work in real Apex, it's not valid syntax. B is the way to check object-level delete permission using
Schema.sObjectType.Account.isDeletable(). I've seen this on practice tests too. Pretty sure that's what Salesforce expects, but open to other reasoning.C or B here. I went with C since it looked like calling isDeletable on sObjectType from the instance, which seemed right in practice. Saw mixed explanations in the official guide and practice tests about this syntax.
B, not A. Had something like this in a mock, B's the right check for object-level delete permission.
B works because it actually uses Schema.sObjectType.Account.isDeletable() which is the standard way for enforcing object-level permissions in Apex, just like the official docs and guides mention. Pretty sure this comes up in practice exams too, correct me if I'm wrong.
B, not C. C is a trap since that syntax doesn't actually exist in Apex, only B calls Schema.sObjectType.Account.isDeletable().
Be respectful. No spam.