Evaluating isSandbox in flow

In Summer 14, Salesforce added the isSandbox boolean field to the Organization object that can be easily queried in apex.

In flow, process builder, and workflow rules, you can access the $organization global variable via a formula field, but a number of fields are missing, including isSandbox

You might think you could hard code the org Id but it wont work, due to magical mysterious things that happen in the sandbox refresh engine, which will update almost all references to the new sandbox org id.

In flow, it is quite easy however to get this info via a get record element. Do a get records on the Organization object (all records), then you can access the isSandbox field, and evaluate it in a decision element.

Get Records
getOrg3.png

Decision Element
isSandboxDec.png

Sadly, this is not available for process builder or workflow rules and my idea for this only has 3 votes in two years, flow is the future…

Note - scheduled flows come over to sandboxes when you refresh them, so if your flows can cause emails to be sent, this could be important. On refresh, user emails are scrambled and deliverability is set to system email only, so it will only have an impact when sending to custom email fields. An alternative is to use an apex class to scramble those fields on sandbox refresh, but you gotta remember to run it!

 
19
Kudos
 
19
Kudos

Now read this

ISCHANGED and PRIORVALUE in Before Save Flows (not for after save flows)

UPDATE - DEC 2020 : Spring21 should offer this natively, per poking in my pre-release org. Will link to release notes when they are available. Before save flows do not directly offer functions like ISCHANGED, ISNEW, and PRIORVALUE ISNEW... Continue →