1

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.
Saariko
  • 5,610
  • 13
  • 75
  • 165

1 Answers1

9

This answer should help you.

Long story short, method:

public static Boolean runningInASandbox() {
  return [SELECT Id, IsSandbox FROM Organization LIMIT 1].IsSandbox;
}
EvAzi
  • 1,041
  • 9
  • 23