Skip to main content
All CollectionsCompare and deploy metadataMetadata filters
Custom metadata filters in Compare and deploy and CI jobs
Custom metadata filters in Compare and deploy and CI jobs

Guidance on how to create, save and share a custom metadata filter

Dario Messina avatar
Written by Dario Messina
Updated over a month ago

What are metadata filters?

When running a comparison between your source and target from the compare and deploy page, the Gearset Default comparison filter includes the most common metadata types, including Custom objects, Profiles, Permission Sets, and Apex code.

If you want more control over which metadata is compared, you can select a different standard filter. Or you can create your own custom filter.

As well as choosing the metadata types to retrieve, such as Apex Class, you can also specify the names of specific items to retrieve using a custom filter. This gives you greater granularity over what to compare.


Gearset remembers your previously selected filter. So, when you select a filter (standard or custom) and then run a comparison with that filter, our app will remember that filter and have it selected when you go to run a comparison again.

Custom filters are used in automation (CI) jobs

Custom filters can also be used for automation jobs, such as continuous integration (CI jobs), and org monitoring. Once you save a filter, it will be available across Gearset in any place that allows you to specify the metadata filter used.

Updating filters in automation jobs

If you edit the custom metadata filter used in a CI job, the job will not automatically use the updated filter.

To update the filter, you'll need to:

  1. On the CI dashboard click on your CI job and select Edit settings.

  2. Click on the Metadata filters tab.

  3. Select your filter from the drop-down menu, and add new metadata types (or any other amendments).

  4. Click Save CI job.

The CI job will now apply your updated filter for all future runs.

Custom metadata filters can be shared with your team

When you save a custom metadata filter, you can choose whether to share it with the rest of your team or if you want to make the filter private (available only to you).

Who can edit filter shared with the team?

When a filter is shared with the team, only its original creator or a team owner can edit and save changes to it. Team members can use the filter but cannot make and save changes to it; they can use Save as to save any changes they make as a new named filter.

Custom filters (private and shared) will appear in your filter menu in the My filters section. You can find them below the all the Gearset standard filters:

Creating and saving a custom metadata filter

  • From the Compare and deploy page in the Metadata deployments section of our app, select the Comparison filter drop-down next to the Compare now button.

  • Then select MANAGE CUSTOM FILTERS

  • In the column on the left-hand side, choose the metadata type(s) you want to include by checking the boxes next to their names or within the metadata list. You can filter down the results using the Filter metadata types search box at the top.

  • If you want to have more granularity over which metadata is retrieved beyond the item types, the Items to include/exclude column is the place to go. This works for the parent component level only. (For example, you cannot exclude custom fields, only custom objects.)

  • From here, you can then specify whether you want to retrieve all the items within a metadata type, or just a subset. By default, the setting will be on All items.

    You can click this slider to switch it to Named items. Be aware that if you switch the slider to Named items before you have selected your source and target orgs, there will be no items listed and the metadata type will not appear in the comparison.

    Note: orgs connected via username and password will not populate the named item list in the custom metadata filter (for more information see our Managing Salesforce org connections documentation).
    You can then use Refresh comparison to select your desired items from that metadata type.

     

  • If you selected a source and target org in the Compare and deploy screen before clicking on Manage custom filters..., Gearset will automatically list all the items in that metadata type. You can then simply select which items to include in the comparison using the checkboxes.

    Note: The named items in the metadata is cached for 15 minutes, and only refreshed after 15 minutes, to reduce the calls to the Salesforce org.

  • You can also use the box at the bottom of this column for filtering. For example, you can use regex to create complex item filters.

    Click on the drop-down arrow next to Object name (as shown on the above screenshot) and select Regular expression:

  • The column on the right-hand side, Include managed packages, allows you to specify if you want to include in your filter metadata related to managed packages. In the Default comparison filter this is set to None, and in the Compare all filter this is set to All. In a custom filter you can select either of these or Choose, which will allow you to add a list of specific namespaces to include in the comparison. If you've already selected your source and target org, we'll load their namespaces and present them as suggestions for you to add to the list with one click.

  • You can also specify which metadata API version you wish to use for this filter using the setting at the bottom. By default, Gearset will automatically identify the highest commonly supported version between both of the environments you're comparing. Unless you have a specific reason to override this, we recommend leaving API version set to Default (highest common version).
    Read more about API versions on our blog post about MDAPI versioning.

  • You are now ready to save your custom filter. To do so, just click on Save filter at the bottom of the filter, then decide whether you want this filter to be available to you only or to the whole team. Don't forget to give it a name before clicking Save filter.

Deleting a custom filter

To delete a custom filter:

  • Click Manage custom filters... and select it from the drop-down in the top left.

  • Click the button Delete filter... with the red bin icon on the top right.

  • Confirm your action by clicking Delete shared filter.

Standard metadata filters

Gearset app comes with seven standard or default metadata filters:

The Default comparison filter contains the most commonly compared objects. For the majority of users, this filter will retrieve all the metadata items you are interested in comparing and deploying between your environments.

To compare all supported metadata types, choose the Compare all filter. This will also include any managed packages.

The Default CI comparison filter includes the most commonly deployed components when setting up a continuous integration job in Gearset.

For detailed information about all our standard metadata filters, feel free to check this article: What is a metadata filter?

Identifying the number of metadata items in each category

When creating a custom filter to speed up comparisons, it can be useful to know which metadata types contain the largest number of items to retrieve, so that you know which types to consider excluding. 

Once you select the source and target on the Compare and deploy screen, Gearset will begin querying Salesforce for the number of metadata items to retrieve in the comparison.

Once this query completes (usually 5-10 seconds) Gearset will display the total number of metadata items.

After the query is complete, opening the Manage custom filters... dialogue will display the number of items to be retrieved in each metadata type.

For example, below you can see that there are 262 Custom objects that will be retrieved using the current filter. Using a custom filter would allow you to specify a smaller number of Custom objects if you wanted to (or if you don't need to retrieve all Custom objects found in your environment).

(Please Note: For Custom objects you can also specify sub-components, such as Custom Field or Record Type, to be retrieved along with their parent metadata which in this case is Custom object).

Note: Due to the way Gearset breaks up large objects, such as Profiles, into their constituent components, you may see a larger number of items in some categories than you expected. This is not an issue, but rather an expected behaviour.

Identifying which items to include in your custom filter

When creating a custom filter, it's important to understand the way the Salesforce metadata API works. Many objects have interlinked dependencies, and to retrieve all the metadata you're interested in, you will need to include all the relevant metadata types.

For Profiles, for example, see this support article on which metadata types you need to include in your filter to retrieve particular subcomponents:
How to retrieve Profiles and their components using Gearset's metadata filter

If you're not familiar with which metadata types you need to include in your filter, we recommend you stick with either the Default comparison or Compare all filters.

For more information, read the Salesforce documentation on the metadata API.

We are always improving here at Gearset and adding in support for new metadata types. If there is a metadata type that you are using and we don't yet support, then please contact us in our in-app chat.

Did this answer your question?