PDI · Question #109
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…
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 ()
How the community answered
(31 responses)- A3% (1)
- B10% (3)
- C13% (4)
- D74% (23)
Why each option
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.
`accountRec.isDeletable()` is not a valid Apex method for checking delete permissions on a specific SObject record variable.
`Account.isDeletable()` is incomplete and incorrect syntax for checking object-level delete permissions; it should be accessed through `Schema.sObjectType`.
`AccountRec.ObjecType.isDeletable()` contains a typo (`ObjecType`) and incorrect syntax for checking delete permissions.
`Schema.sObjectType.Account.isDeletable()` is the correct way to perform field-level and object-level security checks in Apex to determine if the current user has permission to delete records of the Account object type, ensuring the delete operation respects the user's profile and permission sets.
Concept tested: Apex security and CRUD/FLS checks
Source: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_sobject_describe.htm
Topics
Community Discussion
No community discussion yet for this question.