Smarter Salesforce comparisons that hide reordered XML

David Runciman on

Share with

LinkedIn
Twitter

When is a change not a change? Don't worry - that's not the beginning of a bad joke. But it's a riddle that Salesforce devs and admins sometimes find themselves puzzling out. Confusingly, a comparison of two orgs can throw up apparent differences that turn out to be nothing more than reordered XML. Gearset's intelligent comparison engine recognizes and hides these immaterial differences for you, so you can focus on the actual changes you want to deploy.

Brain illustration

Why compare Salesforce orgs at all?

Some Salesforce teams keep spreadsheets listing every change they've made in a dev environment, so they can remember what they'll need to deploy using change sets. But that's massively time-consuming, and rarely results in successful deployments. Using Gearset to compare the metadata between two orgs, or between an org and a Git branch, you'll see the exact differences between your source and target environments. You can then select the new, changed or even the deleted metadata you want to deploy.

Comparisons make deployments more successful. Without them, you're left bundling up a package of the metadata you think you've changed and then trying to deploy it to an org that may or may not be ready to receive that package. That's an extremely error-prone process. But comparisons help you to understand what's been changed in the source org so you don't miss anything you or your teammates have been working on. And they highlight any other differences between the source and target org that might impact the deployment. Ideally, your environments should be nicely in sync, but comparing environments lets you know for sure what you're working with.

Comparison page in Gearset's UI

One of the really useful things about these comparisons is that you can examine the differences in the metadata line by line, which means you can see the exact impact that your deployment will have on the target environment - right down to the fine details. Of course, anything misleading in these comparison results is likely to cause confusion, and some of the Metadata API's quirks can cause problems. The API's nondeterminism in terms of how it retrieves your metadata is a key example, so we've made sure that Gearset can handle this problem for you.

How nondeterminism affects Salesforce comparisons

A process is nondeterministic when the same inputs can produce different results. When you fetch metadata from Salesforce via its API, you might make exactly the same request but receive metadata in a different order each time. This nondeterminism affects various metadata types, but Layouts are a classic example. Comparing this metadata often produces confusing results.

In the example below, the line-by-line comparison of XML in Gearset indicates that several lines of our Layout have been deleted in the source environment, and so will be deleted if we deploy this change.

The XML diff shows lines in the target org

But in fact, those lines of XML haven't been deleted at all. The Metadata API has simply retrieved them from our source org in a different order. We can find the same lines of XML further down in the comparison, where they appear to be new additions to the source environment that don't yet exist in the target.

The XML diff shows lines in the source org

There are several more examples in just this one Layout where apparent additions and deletions turn out not to be differences at all - just a result of reordering in the XML fetched by the API.

It can be unsettling to find all these 'differences' in metadata you're pretty sure hasn't changed. And even if you recognize what's going on, it's frustrating to have your comparison cluttered with these immaterial differences because they make it harder to spot the actual changes you're expecting to find and add to your deployment package.

Gearset irons out these nondeterministic wrinkles

Most diff tools will consider the reordering of XML a change: one section of XML has been added; another has been deleted. But thankfully, you can get all the benefits of Salesforce comparisons without the frustration of cluttered results due to the API's nondeterminism. Gearset's comparison engine is uniquely able to understand Salesforce metadata. We're adding more intelligence to it all the time, and this includes the ability to recognize when apparent differences are just the result of the Metadata API's nondeterminism.

There are a couple of ways that Gearset currently helps you to solve this problem.

Solution 1: Hide reordering in the comparison

At the comparison results page in Gearset, you can hide the differences caused by reordered XML with just one click. In the top right corner of the section showing your line-by-line comparison, there's a Hide reordering checkbox, which does what it says on the tin! Checking that box hides the immaterial differences that are just the result of reordering.

Gif showing the Hide reordering checkbox in action

It's especially useful to be able to do this when the XML has a mixture of material and immaterial differences. Hiding the differences that don't matter makes it much easier to focus on the material changes you might want to deploy.

Solution 2: Automatic resolution for Layouts

We've gone further with Layouts, as they're the metadata type we most often see running into problems due to reordering. When Gearset detects that the only differences in your Layout are the result of reordering, and so there aren't any real differences to show you, it will automatically consider this metadata to be unchanged. As a result, this Layout won't appear in the list of changed metadata and will no longer clutter up your comparison results.

If there are any material differences in your Layouts, they will still appear in your comparison results as normal. And you'll be able to use the Hide reordering checkbox to filter out any immaterial differences, just as you would for other metadata types.

There's more to come!

Being able to hide these immaterial changes in Gearset makes comparisons and deployments that much easier. But this is just one of the ways Gearset is getting smarter, thanks to the work of our team developing Pipelines, our hotly anticipated product update for visualizing, managing and automating your entire Salesforce release process, demoed at our latest DevOps Summit.

The Pipelines team have been busy working on semantic merges, making Gearset able to resolve merge conflicts automatically. Essentially, Gearset understands your Salesforce metadata, recognizes when merge conflicts aren't true conflicts, and resolves those conflicts for you. Merge conflicts easily block up your releases and bring your automation to a grinding halt, so Gearset's semantic merge capability will dramatically reduce the amount of time your team needs to spend resolving conflict by hand, and streamline your release process even further.

Deploy successfully with smarter Salesforce comparisons

If you've already found the Hide reordering checkbox useful during deployments, we'd love to hear from you. And please get in touch if there are other metadata types as well as Layouts that often show up as changed when it's just a case of reordered XML. We're constantly gathering your feedback so we can make Gearset even better every day. Together, we'll keep nudging up that deployment success rate for Gearset users! It's currently at 92%, compared to an average of about 50% for teams using change sets. We know that every improvement to your workflow gets us all closer to the goal of deploying successfully first time, every time.

Running a comparison in Gearset is always a delight for devs and admins. It's like switching on a light! Suddenly, you can see the state of your orgs and exactly what effect your deployment is going to have - no more working in the dark! If you want to check how in-sync your environments are, or see how Gearset's 'compare and deploy' workflow boosts deployment success, begin our free 30-day trial and see for yourself!

Ready to get started with Gearset?