nerdexam
Salesforce

PDI · Question #123

Given the following code snippet, that is part of a custom controller for a Visualforce page: In which two ways can the try/catch be enclosed to enforce object and field-level permissions and…

The correct answer is A. Use if (Schema, sobjectType, Contact, isUpdatable ( ) ) B. Use if (Schema , sobjectType. Contact. Field, Is_Active_c. is Updateable ( ) ). To ensure DML operations respect object-level and field-level security, Apex code should explicitly check for update permissions before execution.

Submitted by eva_at· Apr 18, 2026Logic and Process Automation

Question

Given the following code snippet, that is part of a custom controller for a Visualforce page:

In which two ways can the try/catch be enclosed to enforce object and field-level permissions and prevent the DML statement from being executed if the current logged-in user does not have the appropriate level of access? Choose 2 answers

Exhibit

PDI question #123 exhibit

Options

  • AUse if (Schema, sobjectType, Contact, isUpdatable ( ) )
  • BUse if (Schema , sobjectType. Contact. Field, Is_Active_c. is Updateable ( ) )
  • CUse if (Schema.sObjectType.Contact.isAccessible ( ) )
  • DUse if (thisContact.Owner = = UserInfo.getuserId ( ) )

How the community answered

(39 responses)
  • A
    77% (30)
  • C
    15% (6)
  • D
    8% (3)

Why each option

To ensure DML operations respect object-level and field-level security, Apex code should explicitly check for update permissions before execution.

AUse if (Schema, sobjectType, Contact, isUpdatable ( ) )Correct

`Schema.sObjectType.Contact.isUpdateable()` checks if the current user has object-level permissions to update records of the Contact object, preventing unauthorized DML.

BUse if (Schema , sobjectType. Contact. Field, Is_Active_c. is Updateable ( ) )Correct

`Schema.sObjectType.Contact.fields.Is_Active_c.isUpdateable()` checks if the current user has field-level permissions to update the specific 'Is_Active_c' field on the Contact object.

CUse if (Schema.sObjectType.Contact.isAccessible ( ) )

`Schema.sObjectType.Contact.isAccessible()` checks for read access, which is not sufficient for enforcing update permissions required for DML operations.

DUse if (thisContact.Owner = = UserInfo.getuserId ( ) )

`thisContact.Owner == UserInfo.getUserId()` checks record ownership, which is a business logic condition, but it does not enforce object or field-level security permissions.

Concept tested: Enforcing object and field level security in Apex

Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_perms_enforcing.htm

Topics

#Apex Security#CRUD/FLS Enforcement#Schema Class#DML Operations

Community Discussion

No community discussion yet for this question.

Full PDI Practice