I have a global class in a managed package and want to change it from with to without sharing in a new release.

Is this possible? Could I do this in a patch?


Like told from Novarg before, you can change the sharing of a global class. I have already modified the sharing of global classes previously and I have not encountered any problems. Remember that for the security review, you have to explain the reasons why a class is branded "without sharing".

  • Thanks. Did you do this in major releases or patches (or both)? (And, yes, I am well aware of the security review implication!) – Phil W Nov 28 '19 at 16:22
  • I did it with the major release, didn't try with the patches, but I think you can do it too. – Andrea P. Nov 29 '19 at 9:07
  • OK. I'll wait and see if someone can confirm patch compatibility before marking your answer as best... thanks. – Phil W Nov 29 '19 at 10:28

According to the documentation, you can edit API version and the code of the class, but not the name. Given that with sharing and without sharing is not a part of a name, I would say that you can change it.

  • Thanks. Unfortunately the documentation is, as often the case, rather vague which is why I wasn't relying on it directly and hoping someone might have first-hand experience of such a change. – Phil W Nov 28 '19 at 9:47
  • Regarding the documentation, this says we can edit the code which is true, but it isn't possible to change the signature of a global method, or to remove one, once the package is released. This is what I mean by vague. To find out all the various nuances you either have to be lucky in finding the right documentation, learn from someone else's experience or you have to try it yourself. The latter is a problem with managed packages since you can only find out very late in the SDLC for a change. – Phil W Nov 28 '19 at 9:57
  • oh, ok. Personally I do not have much experience with managed packages, so I can not give you a first-hand answer to it. But what you can try(I think) is creating a patch and pushing it only to your test org to see if that works. – Novarg Nov 28 '19 at 11:09
  • that would cover off part of my question, for sure. However, there are differences in the constraints applied at patch and release level too :( – Phil W Nov 28 '19 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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