Apex Class with sharing and Without Sharing

Monday, July 20, 2015
With Sharing - Enforce the sharing rules that apply to current user.

For example : 

public with sharing class yourClassName {

// Your code goes here

}

Without Sharing - Doesn't enforce the sharing rules.

For example : 

public without sharing class yourClassName {

// Your code goes here

}


Note : If with or without sharing are not mentioned with class then default is "Without sharing".

No comments: