O'Reilly logo

Visualforce Developer's Guide by W.A.Chamil Madusanka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Data access control

The Force.com platform allows us to configure object permissions (read, create, edit, and delete) and create data sharing rules. We can implement security controls using those features. The standard controllers adhere to these security settings. But the custom controllers and controller extensions can access all the data during the execution. This is the default behavior, but we can control the data access from Apex classes using the with sharing keyword. The keyword is used as follows:

public with sharing class ExampleController {
  public void methodOne()
{
      List<Item__c> = [Select Id, Name FROM Item__c WHERE Id IN: itemIds];
}
}

The with sharing keyword forces the Apex class to consider the security sharing permissions of the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required