The query will return true
for Organization.IsSandbox
when this code is run as part of a sandbox refresh.
I ran the following class:
global class SandboxRefreshClass implements SandboxPostCopy {
global void runApexClass(SandboxContext context) {
insert new Account(name = 'Context Org Id: ' + context.organizationId() + ' Context Sandbox Id: ' + context.sandboxId());
insert new Account(name = ' UserInfo Session Id: ' + UserInfo.getSessionId() + ' UserInfo Org Id: ' + UserInfo.getOrganizationId());
insert new Account(name = ' Organization IsSandbox: ' + [SELECT IsSandbox FROM Organization].IsSandbox);
}
}
And got the following results:
Context Org Id: /* 15 digit sandbox org id */
Context Sandbox Id: /* 15 digit sandbox id (07E not 00D)*/
UserInfo Session Id: null
UserInfo Org Id: /* 18 digit sandbox org id */
Organization IsSandbox: true