Execute Apex code over Sandbox environment only, but have it on production as well 🔥 🔥
public Class Helloword
{
public void runlogicOnSandboxOnly()
{
Boolean isSandbox = IsrunningInASandbox();
if (isSandbox)
{
// code for Sandbox only
}
}
public Boolean IsrunningInASandbox() {
return [SELECT Id, IsSandbox FROM Organization LIMIT 1].IsSandbox;
}
}