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.

1 Answer 1


This answer should help you.

Long story short, method:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .