PDI · Question #109
PDI Question #109: Real Exam Question with Answer & Explanation
The correct answer is D: Schena, sobjectType, Account, isDeletetable (). To ensure an Apex method respects user permissions before deleting an Account, the developer must use Schema.sObjectType.Account.isDeletable() to check if the current user has delete access on the Account object.
Question
A developer must write anApex 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 deletion?
Options
- AaccountRec., isDeletable()
- BAccount, isDeletable ()
- CAccountRec, ObjecType, ieDeletable ()
- DSchena, sobjectType, Account, isDeletetable ()
Explanation
To ensure an Apex method respects user permissions before deleting an Account, the developer must use Schema.sObjectType.Account.isDeletable() to check if the current user has delete access on the Account object.
Common mistakes.
- A.
accountRec.isDeletable()is not a valid Apex method for checking delete permissions on a specific SObject record variable. - B.
Account.isDeletable()is incomplete and incorrect syntax for checking object-level delete permissions; it should be accessed throughSchema.sObjectType. - C.
AccountRec.ObjecType.isDeletable()contains a typo (ObjecType) and incorrect syntax for checking delete permissions.
Concept tested. Apex security and CRUD/FLS checks
Topics
Community Discussion
No community discussion yet for this question.