Skip to main content

Why custom labels cannot be filtered

Custom Labels XML structure and why individual labels cannot be filtered

Written by Mykyta Nechepurenko
Updated over 2 months ago

Custom Labels XML

In the Salesforce Metadata API, Custom Labels are structured differently from many other metadata types:

  • CustomLabels is the top-level metadata container.

  • Individual labels are represented as CustomLabel entries.

  • Each CustomLabel is a subcomponent of the CustomLabels metadata type, not a standalone top-level metadata object.

Example:

<?xml version="1.0" encoding="utf-8"?>
<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
<labels xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Order_Status_Message</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>Order Status Message</shortDescription>
<value>Your order is being processed</value>
</labels>
<labels xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Order_Shipped_Message</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>Order Shipped Message</shortDescription>
<value>Your order has been shipped</value>
</labels>
</CustomLabels>

Root element is <CustomLabels>. Each label is a <labels> node (representing an individual CustomLabel subcomponent).


As a result, all individual labels are stored and retrieved together as a single metadata file.

Why these cannot be filtered today

Retrieval filters only operate on top-level metadata items. As a result, subcomponents (such as individual CustomLabel entries) cannot be filtered independently.
​
This behavior is not specific to Gearset, but rather a constraint imposed by the structure of the Salesforce Metadata API.

This limitation is a known issue, and there is an open suggestion in the Gearset feedback forum proposing support for filtering individual CustomLabel entries.
​

If this functionality would be valuable for your workflow, we encourage to vote for the suggestion in the feedback forum to help prioritize its implementation.

Did this answer your question?