I have created a couple of classes and a flow, that fill my sandbox with random data.

I want to have these classes available to all future sandboxes that I create, but I don't want to enable that class to run on my production org. I will deploy them to my production org for future sandboxes.

  • I am the only admin, and I know I can control this, but I want to know, if I can code anything that will prevent a certain class to run in production org.

This answer should help you.

Long story short, method:

public static Boolean runningInASandbox() {
  return [SELECT Id, IsSandbox FROM Organization LIMIT 1].IsSandbox;

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.