What will automatically obey the organization wide defaults and - ProProfs Discuss
Topics
Products
Follow Us:

What will automatically obey the organization-wide defaults and sharing settings for the user who executes the code in the salesforce organization?
Reference: A developer has a block of code that omits any statements that indicate whether the code block should execute with or without sharing. 

What will automatically obey the organization-wide defaults and sharing settings for the user who executes the code in the salesforce organization?

<br/>Reference: A developer has a block of code that omits any statements that indicate whether the code block should execute with or without sharing. 

Change Image    Delete

A. Apex Triggers
B. HTTP Callouts
C. Apex Controllers
D. Anonymous Blocks

This question is part of

Platform Dev I
Asked by Holly, Last updated: Mar 28, 2020

+ Answer
Request

9 Answers

G. Roland

G. Roland, Professor, Austin

Answered Jul 09, 2018

The answer is Anonymous Blocks. With the choices that are available, it can be confusing if this is the option or Apex Trigger. Apex Trigger can be used in order to compile data and execute everything that is needed. Apex Trigger can be used in system mode but it is only Anonymous Blocks that can help get user permissions.

Remember that you cannot use Apex Triggers if you want to update a field if you would not be able to use it. You cannot use the other codes that are given to you. The Apex code can get stuck in the metadata but it can be executed when needed.

1
 

John Adney

John Adney

Answered Feb 18, 2017

Anonymous Block and Apex Triggers and not Apex Controllers (you have specify with sharing in order to take effect) , but with Apex Triggers you can't update a field if user can't access it.
1
 

padrinathp

Anonymous Blocks is correct.

1
 

vinay.oy

Anonymous Blocks only.
1
 

SFDC Dev

SFDC Dev

Answered Aug 07, 2017

Ans is Apex Trigger.

Though Anonymous block can be excuted in devleoper console without sharing/permission, it need Authour Apex to be enabled for API access. Thus it does comes under normal OWD. But trigger is irrespective of any enabling checkbox.

1
 

BunniesKill

Anonymous Blocks is correct.
 

mudasirwani

If we use with sharing on controller it will also take care.
C. Apex ControllersD. Anonymous Blocks
 

michaelwit

Apex Triggers execute in system mode. Only Anonymous Blocks take account of user permissions.
 1

neelesh.dwivedi

Agree with Michaelwit, triggers execution happens on system mode.

Thanks

John Smith

John Smith

Answered Sep 08, 2016

Apex Triggers
2. Anonymous Blocks
 

Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer

Email Sent
We have sent an email to your address "" with instructions to reset your password.