Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am about send my package for Security Scanner, So Is there any requirement to add "with Sharing" for all of my Batch Classes.

global with sharing myBatch implement Database.Batachable<sObject> {}

or

global myBatch implement Database.Batachable<sObject> {}

this will not cause any scanner isuue ?

share|improve this question
1  
Do you need this class to be global? I ask because many of the examples still (for historic reasons) have global in them, where using the public access modifier will work just fine and thus your class will not be subject to the eyes of the security scanner. If you don't need your subscriber org developers to see this class, easiest option is just to make it a public class. –  Andrew Fawcett Jul 17 at 7:32

1 Answer 1

I have just submitted a security scanner and did not add with sharing to my batch classes. The scanner did not complain. However it is allowable to have a class that is without sharing that pops up a red flag in the scanner and for the Security Review team to let it pass if you can justify why you have done it and that you are not just ignoring sharing rules but bypassing them for a valid reason

share|improve this answer
    
Batch classes are often used for housekeeping and therefore need to run without sharing. However, if the batch processes user-facing data, such as a batch data export, then it may be recommended. –  sfdcfox Jul 17 at 14:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.