function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
anjin reddy 9anjin reddy 9 

how to get the name of sandbox

Hi Friends,
  How to get name sandbox ...Example weather its like Developer ,full copy ,or partialy sand box ....as well as Total number of sandbox are used 
\

Thanks in advance
Anjin
krishna chaitanya 35krishna chaitanya 35

Organization myOrg = [Select o.WebToCaseDefaultOrigin, o.UsesStartDateAsFiscalYearName, o.UiSkin, o.TrialExpirationDate, o.SystemModstamp, o.Street, o.State, o.ReceivesInfoEmails, o.ReceivesAdminInfoEmails, o.PrimaryContact, o.PreferencesRequireOpportunityProducts, o.PostalCode, o.Phone, o.OrganizationType, o.Name, o.MonthlyPageViewsUsed, o.MonthlyPageViewsEntitlement, o.LastModifiedDate, o.LastModifiedById, o.LanguageLocaleKey, o.Id, o.FiscalYearStartMonth, o.Fax, o.Division, o.DefaultPricebookAccess, o.DefaultOpportunityAccess, o.DefaultLocaleSidKey, o.DefaultLeadAccess, o.DefaultContactAccess, o.DefaultCaseAccess, o.DefaultCampaignAccess, o.DefaultCalendarAccess, o.DefaultAccountAccess, o.CreatedDate, o.CreatedById, o.Country, o.ComplianceBccEmail, o.City From Organization o];

That will retrieve you the organization details in Apex Code.
FYI-https://www.salesforce.com/us/developer/docs/pages/Content/pages_variables_global_organization.htm

Thanks
Krishna.
srlawr uksrlawr uk
Hi, I'm not sure if you are asking how to do this through the UI or the API, so I'm just going to dump a load of knowledge I have on this area for you.

You can get the Sandbox name through the UI using the black box in the top right corner:

User-added image

From within each Sandbox, you can't (as far as I know) detemine the type of the Sandbox, but the easiest way to work out where you are is to go to Setup > System Overview and look at the Data Storage:

User-added image
Got 200Mb? Thats a developer sandbox, up to 1Gb, that's a Developer Pro... But got 5Gb? Thats a partial copy Sandbox.

The only real way to tell is to log into the live enviroment and go to the sandboxes page via Setup > Deploy > Sandboxes.  (note: there is no Sandboxes menu item IN sandboxes).

This will tell you all you need to know about your Sandbox setup in this org (such as type, name and instance)

User-added image


Via Apex, to determine if you are in a Sandbox or live, there is a "IsSandbox" field on the Organisation data, which you can access like:
Boolean isSandbox = return [SELECT IsSandbox FROM Organization LIMIT 1].IsSandbox;
and that will tell you if you are in a Sandbox or not. There is also a field called "InstanceName" which gives you the server cluster your organisaiton is on (such as NA2, CS17 etc.etc.).

It is kind of possible to get the Sandbox name by examining the end of a username - so long as the user hasn't changed it. I would never endorse this kind of solution in production code, because it is kind of dependant on user data, and also a little flakey in my opinion, but you could load a single ("random"?) user account and examine the last "word" - after the last fullstop?! but I can think of half a dozen reasons that might go wrong!

No I think about it, actually... I bet using the Metadata or Tooling API you can get that info. I should have just researched that for you..