Auto-Classify Retention Label in Office 365, based on Metadata

Retention label provides a way to enforce data lifecycle policy on your specific content (e.g. how long to retain it, when to dispose of it).  You can deploy a label to be manually set (by an end user) or to be automatically classified by Office 365.

With auto-class, Office 365 can automatically assign a label, based on a certain condition (e.g. sensitivity type or keyword query), which removes the burden from your end users to be compliant.  A new addition to auto-class is the ability to auto-classify documents, based on SharePoint Content Type and metadata value.  This is great for organizations with a lot of structured content and stringent records retention requirements.  And label auto-class on metadata will be the focus for this post.

Special thanks to the ever awesome Julia Kastenhofer, Naga Kuchi, and Jean Facchin for the huge assist!

The Magic is in Search

Before jumping to auto-class, you have to make sure that things work in SharePoint Enterprise Search.  If your query doesn’t populate any search result, then your query won’t work in auto-class.

Take Content Type, for example.  If you had a Memo Content Type, then typing contenttype:Memo in Enterprise Search should show search result.  And creating a retention label policy using the same contenttype:Memo query would auto-classify the label on those documents.

If you had other metadata-specific needs for auto-class, follow the details below:

Search Step 1 – Crawled Property

Look for the Crawled Property of your SharePoint column in the SharePoint Admin Center Search Schema. A few notes when searching for your crawled property:

  • If you just created the custom column, you may need to wait for it to appear in Crawled Properties
  • Search Crawled Properties for your SharePoint internal field name (since field name can be changed, i.e. your “Project Status” field could actually have a “Mother_x0020_Of_x0020_Dragon” internal field name)

Once you locate your crawled property, take a note of it, since you will need this on the next step.

Search Step 2 – Map crawled property to Refinable Managed Property

What’s next is to introduce the search to your crawled property.  To do so, we will use a Refinable Managed Property.  These are pre-created SharePoint managed properties (e.g. RefinableString00, RefinableDate12) that you can use to associate your crawled properties with.  Search for the word “Refinable” in Managed Properties and you’ll see A LOT of properties and data types to work with.

Once you locate and click on a Refinable Managed Property, then find the “Mappings to crawled properties” section and click on “Add a Mapping” to map your crawled property.

After saving the changes, validate that your crawled property has been properly mapped to the defined Refinable Managed Property.

Search Step 3  – Validate in Enterprise Search

Go to Enterprise Search, either in Microsoft Search (via or SharePoint Classic search (i.e. to validate the crawled property mapping.  The keyword format to use in search is important, because you will use the same syntax when applying auto-class for the retention label:

YourRefinableManagedProperty:”Your Metadata Value”

For my example, the keyword search will be RefinableString01:”Cat” since I have a document tagged with a value of “Cat” in the “Custom Text” column (which is mapped to RefinableString01).  And voila, search result picked it up!

Keep this search keyword handy because you will need it later, when setting the auto-classification rule for your label.

Assign Auto-classification Label Policy

From the Classifications section in the left nav of Security & Compliance Center (or M365 Compliance Center), find (or create) the label that you want to auto-class.  Select the retention label then click on “Auto-apply a label”

Get to the “Condition” section then select the 2nd option to “Apply label to content that contains specific words or phrases.”  When you proceed, you will presented with the Keyword query editor.  This is the place to place your search keyword into (with format of YourRefinableManagedProperty:”Your Metadata Value”).

The KQL syntax operator is fair game here, so explore your creativity with the ANDs, the ORs, the parenthesis to get the segmentation that you’re looking for.

Once you’re happy with your keyword query, click Next to name your policy then specify the location (e.g. certain mailboxes and/or SharePoint site collections) that you want to enforce this policy upon.

Proof is in the pudding

From there, let auto-class take care of the rest! Note: it may take up to 7 days for auto-class to kick in.

Variation with Managed Metadata Service (MMS)

Mapping a Managed Metadata column to a Refinable Managed Property is also supported (e.g. RefinableString:”Some MMS Term Here”).  So that could bring rejoice to your fellow librarians and record managers.

Furthermore, you can reference the term GUID in MMS, instead of using the term name.  This provides for a better taxonomy control, so you can change a term name in the Term Store and not have to worry about the impact on auto-class. So everybody wins!

From the Term Store, click on your Term, then find the “Unique Identifier” at the bottom.

If you placed a pound before the GUID (e.g. #21d06949-7b8b-420f-ae54-01e84dbc8d7c), this syntax should work for Search and Auto-class, i.e. Office 365 will find any documents that are tagged with this Managed Metadata term and apply the corresponding retention label.


  • Auto-classification requires Advanced Compliance (via Office 365 E5 or Information Protection & Compliance offering)
  • Managed Properties, outside of the Refinable Managed Properties (as outlined in this post), are not currently supported for auto-classification
  • Document Sets aren’t currently included in the scope of auto-classification

Thanks for reading!



  1. Hello Bobby, im am note sure if i understand this the right way – Does this mean you can also apply Site Columns from the contentTypeHub as well ?. We need our retention policies to work tenant wide.

    • Yes, Brendan. Retention policies and retention labels can published to specific site collection or to the entire tenant. If you need the same Site Column in multiple site collections, then you would need Content Type Hub to publish that column (at this time. Hub Site could allow for more flexibility in the future).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s