Gogagah|Sandboxes are used to create copies of the Salesforce org in different environments. You can use Sandboxes for development of the applications, testing, and training without any compromise on the applications and data in the production org. If you want to customize the organization in different staging environments without tampering your production org and its users, then Sandboxes can be used. You can also have an organization which users can easily log into and test the features before they are ready for production. You may also simply log into the Sandbox for training and development of actual Salesforce organizations by easily mirroring the production org.

Creation and cloning of a Sandbox

As discussed above, you can create a sandbox for easy development, testing, and training in a different environment. Simply clone the sandbox to copy the data content and metadata to another sandbox. You can also refresh a sandbox for updating content.

Managing Sandboxes

  • Access the Quick Find box on the Salesforce home page and enter Sandboxes.
  • The available sandboxes and those who are in use will be displayed.
  • You can manage the Sandboxes programmatically.
  • Use the Salesforce CLI to create, authorize, and clone Sandboxes.
  • Admins create and manage sandboxes using a setup user interface. But, as there is a need to manage development and testing environment programmatically Salesforce CLI enables it.
  • You can migrate the metadata changes between various Salesforce org with the use of deployment tools from the setup.

Staging environments for testing

If you want to customized orgs at different staging environment to test the changes without affecting production orgs or the users, then Salesforce sandboxes can be used for this purpose. You can also maintain an organization where the users can log in and test the features before they get into production. Sometime, the need may be to just log in to any Salesforce organization for development or training by mirroring your production org, which also is enabled by sandboxes.

Salesforce now offers many deployment tools with which you can do the following tasks:

  • Isolate the development and customization tasks from production environment until they are ready to deploy the changes.
  • Test your changes made against the different copies of the production data and its users.
  • Provide an optimized training environment.
  • Effectively coordinate the individual changes made in deployment to the process of production.

Even if you are an admin adding or changing the features to an org or a developer who is preparing codes, working with the right tools at the right environment is important to build and deploy production organization effectively. To get a perfect overview of the development process and for proper recommendations to organize your work, you can explore the Application Development Lifecycle module on the Salesforce Trailheads.

Sandbox Templates

As we have seen, Sandboxes are standalone entities, so the actions you perform on sandboxes will not reflect on the production orgs. You can custom create various sandbox environments for the orgs based on the need for configuration, storage, and refreshing frequencies, etc.

Creating Sandbox

When creating a new sandbox, Salesforce may copy all the metadata from production org to the sandbox org. On refreshing, the metadata will get updated from the source org. If a sandbox is made as a clone or uses any template, then the refresh process may update the org data too apart from metadata.If you haven’t chosen the Auto Activate option while doing sandbox refreshing, then you must first activate the sandbox before using it. You can also create sandbox by cloning a sandbox than creating fresher using production org. With this, you can save a considerable amount of time taken to customize a sandbox with a custom set of data or metadata. The cloning process will also simplify the process by having various concurrent work streams in the application development life cycle. The developers can set up a unique sandbox for each work type like development, staging, and testing, etc. The team members can easily clone the individual sandboxes rather than sharing a single sandbox in order to avoid confusions.

Selecting data to be included in your Sandbox

A Partial Copy sandboxes, you can just click Next and choose the right template created to select data for the sandbox. If there is no template created for Partial Copy sandbox, then you can first go to Create / Edit Sandbox Templates option. For creating a Full Sandbox, click on Next and decide the volume of data to be included. To include any data which are template-based into a Full sandbox, choose an existing template and then add data.In order to include complete data into Full sandbox, first, choose how much field tracking data needs to be included and whether there is a need to copy the Chatter data. You can easily copy a history from 0 to 180 days in the past and set it in 30-day increments; default can be set as zero days. The chatter data copied by could also include messages, feeds, and discovery topics, etc. Decreasing the data volume will help you copy at significant speed and reduce the overall copy time for the sandbox. 

In order to run the scripts after each creates operations or refreshing the sandbox, you may specify the Apex class that you created previously from the PostCopy interface of the particular Sandbox. The process may take several minutes to many days based on the size of your org and its type. Once your sandbox is ready to use, you may receive an email notification as the sandbox had finished copying. In order to access the sandbox created, you may simply click on the link given in the notification mail. Users can also log on to the sandbox by choosing it from the URL, You can directly go to the sandbox by appending the extension as ‘.sandbox_name’ to the Salesforce usernames. While creating sandboxes, one important thing to remember is that Salesforce may change the sandbox usernames automatically. Newly created sandboxes will have email deliverability for system mails. Hit System email setting s very usefully to control the emails sent from sandboxes so that the testing and development tasks cannot send test emails to the actual users.