Best Practices

Metadata Refreshes and Comparing Salesforce Orgs with Git

Learn how to refresh metadata on your Salesforce sandbox, compare differences between Salesforce orgs, and streamline development with Git and Blue Canvas.

Last Update:
May 29, 2023
Published:
January 9, 2018

After reading this article, you will learn how to refresh metadata on your Salesforce sandbox, compare the differences between Salesforce orgs, and utilize dedicated solutions to synchronize metadata and improve the development process.

Here are our 5 key takeaways:

  • Adopting Git for Salesforce development and continuous integration practices promotes org synchronization and helps avoid potential synching challenges
  • Leveraging tools that integrate with Git allows developers to pull metadata from the production or master branch into their sandbox swiftly.
  • Specialized tools enable you to easily compare metadata differences between your production org and sandbox, ensuring consistency in your development environment.
  • These tools automatically track metadata changes, providing a comprehensive version control history for your Salesforce orgs.
  • Instead of relying on sandbox refreshes, which can be time-consuming and may result in lost changes, these tools offer efficient ways to sync metadata between orgs.

Table of Contents

Refreshing Metadata on Your Salesforce Sandbox

It’s Monday morning and the start of a new sprint. Friday was a huge success: you did a major deploy and demo to your business stakeholders. It was a massive success. You emerge from the weekend’s celebratory bender in a state of peaceful, if a bit groggy, bliss. Despite your newly exalted place in the hearts and minds of your colleagues and loved ones, you sit down to start coding anew. You aren’t one to rest on your laurels after all.

But there’s something that kind of annoys you: your development sandbox is not in the same state as your production environment. Multiple sandboxes were involved in contributing to the last release. A few features came from your sandbox, some changes to Triggers and Workflows came from a colleague in India, another set of Apex changes came from a colleague in New York.

Before you start coding again, you want the metadata on your sandbox to be the same as what’s running in production now so you can avoid merge conflicts and code from a clean state.

But before you can even do that, how do you know what’s different between your Salesforce Orgs? What’s present in production that isn’t on your sandbox (and vice versa)?

Accurate Comparison of Production Org and Sandbox

Blue Canvas also makes it easy to compare what’s actually happening on various Orgs via Git diff. We offer a simple UI for comparing differences between Orgs in real time.

Knowing what is different between your production Org and a sandbox or UAT environment can be extremely useful. Blue Canvas tracks each Org with it’s own Git branch. When changes happen on the Org, whether through the Salesforce UI or dev console or are uploaded via the Force.com migration tool or MavensMate Blue Canvas automatically pics them up and commits them to Git. This happens in real time so you can be confident that your comparison is accurate.

Most importantly, Blue Canvas tracks metadata changes automatically. So if someone makes a change directly in production and forgets to commit it or tell anyone, it will still show in your version control history. If someone updates a field or changes a Layout, that will be captured automatically.

With Blue Canvas everything is automatically present and backed up in your Git history and fully available to pull and compare using our UI.


Syncing Orgs for Seamless Development: Bridging the Gap Between Sandboxes and Production in Salesforce

Now that you’ve seen the difference in states, how do you make them one again?

Some developers will use a Sandbox refresh to sync the metadata on an Org, but as any Salesforce developer knows, this is not an ideal solution to this problem. Refreshes are data intensive and so there are limits on how many refreshes you can do in a given month. Furthermore once you request a refresh it can take days to complete. In the meantime, any changes you made will be lost when the refresh eventually does happen.

This is a major constraint on velocity and an impediment to continuous integration for Salesforce.

It also causes many developers to not work on sandboxes which are not fully up to date. So they’re coding and running tests against an outdated Salesforce Org - a dangerous proposition. When they eventually release to production, the tests run against the real version and may now fail.

Or let’s say you are about to do a release. You want to see what’s different between your Org and your colleague’s Org. You want to merge the code together and test it before pushing it to UAT or Production. How do you get data from an Org into your local environment?

Simplifying Metadata Refreshes with Salesforce-specific Git Implementation

Blue Canvas offers a Salesforce specific implementation of Git that provides a solution to this problem.

Blue Canvas creates a Git repo for you that is connected directly to your Salesforce Org. Refreshing the metadata on your sandbox is then as simple as issuing a git pull from a given Git branch (in this case your production or master branch). This takes a few seconds with Blue Canvas rather than a few days.

Because Blue Canvas automatically tracks all metadata changes that happen on your Org, we can help speed up the development process by keeping your various orgs in sync.

This is a best practices for CI and Salesforce development generally and will prevent innumerable headaches down the line.

Blue Canvas Git Command Line Instructions

Clone into a local directory

git clone -o salesforce -b demo1 https://git.bluecanvas.io/YOUR_USERNAME/YOUR_REPO_ID.git

Add as a remote to existing directory

git remote add salesforce https://git.bluecanvas.io/YOUR_USERNAME/YOUR_REPO_ID.git

Compare branches

git fetch salesforce
git diff master...salesforce/BRANCH_NAME

Streamline Metadata Management with Blue Canvas

Adopting Git and Salesforce Deployment Tools provides an efficient solution for refreshing metadata and comparing differences between Salesforce Orgs. By leveraging these tools, you can easily synchronize orgs, avoid merge conflicts, and maintain a clean code state. Blue Canvas's Salesforce-specific implementation of Git creates a connected Git repo for your Salesforce Org, allowing you to refresh metadata on your sandbox with a simple git pull command. 

With automatic tracking of metadata changes, Blue Canvas ensures accurate version control history and facilitates the development process. Incorporating these best practices in CI and Salesforce development will enhance efficiency and prevent future challenges. 

Take advantage of Blue Canvas today to streamline your metadata management and drive seamless development.

FAQ: Metadata Refreshes and Comparing Salesforce Orgs

How can I compare Salesforce Orgs to identify differences?

  • Blue Canvas offers a simple UI for comparing differences between Orgs in real time via Git diff. You can easily see what is different between your production Org and sandbox or UAT environment.

What tools can I use to compare metadata differences between Salesforce Orgs?

  • Blue Canvas provides specialized tools that enable you to easily compare metadata differences between your production org and sandbox. This ensures consistency in your development environment.

How does Blue Canvas track metadata changes in real time?

  • Blue Canvas tracks each Org with its own Git branch and automatically picks up and commits metadata changes in real time. Whether changes are made through the Salesforce UI, dev console, or uploaded via tools like Force.com migration tool or MavensMate, Blue Canvas captures them accurately.

Can Blue Canvas automatically synchronize metadata between Salesforce Orgs?

  • Yes, Blue Canvas automatically tracks metadata changes and provides a comprehensive version control history for your Salesforce orgs. This helps in synchronizing metadata between orgs efficiently.

Why is a Sandbox refresh not an ideal solution for syncing metadata on Salesforce Orgs?

  • Sandbox refreshes can be time-consuming, data-intensive, and may result in lost changes. There are also limits on the number of refreshes you can do in a given month. Blue Canvas offers more efficient ways to sync metadata between orgs, avoiding these limitations.

How does Blue Canvas help developers work with up-to-date sandboxes?

  • By automatically tracking metadata changes and providing a Salesforce-specific implementation of Git, Blue Canvas keeps your various orgs in sync. This allows developers to work with up-to-date sandboxes, ensuring they code and run tests against the latest Salesforce Org version.

How can I merge code and test the differences between Orgs before pushing to UAT or Production?

  • With Blue Canvas, you can use Git to compare branches and see the differences between your Org and your colleague's Org. This allows you to merge the code together, test it, and ensure its compatibility before pushing it to UAT or Production.

What is the Salesforce-specific implementation of Git offered by Blue Canvas?

  • Blue Canvas creates a Git repo connected directly to your Salesforce Org. You can refresh the metadata on your sandbox by issuing a git pull from the relevant Git branch (e.g., production or master branch) in just a few seconds.

How does Blue Canvas simplify the process of refreshing metadata on a sandbox?

  • Blue Canvas eliminates the need for time-consuming sandbox refreshes. Instead, you can use Git to pull metadata from a specific branch into your sandbox swiftly, ensuring your sandbox is up to date with the production environment.

What are the best practices for continuous integration and Salesforce development using Blue Canvas and Git?

  • By adopting Git and leveraging Blue Canvas, you can promote org synchronization, avoid syncing challenges, and improve the development process. Blue Canvas's automated metadata tracking and efficient synchronization methods align with best practices for continuous integration in Salesforce development.

More like this