Have record retention labels been applied to content across SharePoint Online sites and you now want to find ways to search for and filter by them? The Content Explorer is a great feature within the Compliance Center to show you where retention labels, including record retention labels, have been applied to content across your tenant (extending beyond SharePoint to OneDrive and Exchange); however, sometimes there’s a more targeted need from records managers, data stewards, and site administrators to understand a bit more about records at a site level.
Disclaimer: for purposes of this post, the term “record” is referring to a document that has had a retention label applied to it that is configured to mark the item as a record. It can be locked and unlocked to make content changes.
Rolled out worldwide (January 2022), you can now disable unlocking of records at a tenant level.
Currently in preview, you will soon be able to set the default(initial) state of a record at a tenant level to be EITHER unlocked or locked. That change does not affect the content of this post.
Practical scenarios/questions answered in this post:
- “Show me all records that are currently in an unlocked state in my site so I can follow up”
- “Show me all records in this site, whether they’re locked or unlocked”
- “Show me all locked records in this site”
By combining the power of Microsoft Search, some search configuration, and record retention labels applied to content across your tenant, you can answer all of the above questions in fairly short order.
I recommend configuring your search schema settings at the tenant level to allow for searching for locked and unlocked records across your entire tenant, specific site, or specific library in a consistent way. Once the search configuration is done, you can use the same search query within Content Search, Microsoft Search, or build a custom search page to target any of those locations.
In this post, I’ll show a modern page where I’ve added some PnP Modern Search web parts to help deliver the record search results to users in a helpful way.
- Map 2 crawled properties in the tenant-level search schema to RefinableInt managed properties
- Build and test the query and execute using Microsoft Search box
- [Optional] Build a modern SharePoint page with PnP Modern Search web parts
Step 1: Mapping crawled properties
When a record retention label is applied to a document in SharePoint, many things happen behind the scenes; however, for visual reference, a column called ‘Item is a record’ is populated with a value of either Yes or No depending on its locked state. If locked, a lock icon will also appear beside the document name. End-users can unlock and relock a record while making changes; however, as long as the record retention label remains on the document, it is still considered a record.
If you wanted to quickly see the number of records in a library, you could use the Item is a record column in a SharePoint document library to filter and group; however if you have a large library with many folders and/or several libraries on one site, you may want to have an easier way to consolidate a view of all your records at once. You may also need to know which of those records are currently in an unlocked state.
Search is your friend to get this done. 🙂
There are several search crawled properties persisted with values when a record retention label is applied to an item and then subsequently locked and unlocked :
- TagPolicyRecord | this property has the value 1 when a record label has been applied and it is in a locked state
- TagPolicyRecordUnlocked | this property has the value 1 when a record label has been applied and it is in an unlocked state
- ows__IsRecord (from my testing this appears to be a set of numeric values to indicate state and type and, in my opinion, not as user-friendly to use in queries as the above 2 crawled properties. Since the above 2 properties align perfectly with what I need, I won’t be using this one)
I’ll map the first 2 crawled properties above (TagPolicyRecord and TagPolicyRecordUnlocked) to 2 of the pre-built RefinableInt managed properties in the tenant-level search schema:
If you’re familiar with SharePoint search, the mapping for managed properties will be refreshed in the search index on the next full crawl of the item so you will need to re-index at least 1 site with records (both locked and unlocked) to allow you to test your queries. This will ensure the RefinableInt managed properties are updated in the search index.
Step 2: Test with Microsoft Search
To verify the results we’re seeing, I seeded some records in 2 libraries across a site. As you can see, all documents with a record retention label have the Item is a Record column set to Yes; however once it is unlocked the only visual indication to you is the lock icon is removed from beside the document name. I’ve also intentionally applied different record retention labels, regular (non-record) retention labels, and have left some documents unlabeled:
From the above seeded content, I expect to get 5 locked records and 2 unlocked records from 2 libraries returned in the search results when I use the Microsoft Search box from the home page of the site.
I will use these 2 queries to test this:
- Query to find locked records is RefinableInt02=1
- Query to find unlocked records is RefinableInt03=1
As you can see by these images, the correct results are returned:
Step 3: Build a custom search page
Fantastic! With the search queries validated, the world is your oyster! With some knowledge about building modern search pages, you can create a custom one on any SharePoint site to suit your Records Managers’ needs.
For example, below is a custom page I built using the PnP modern search web parts to show records across the current site, the record retention label applied, when it was last modified, and filters to show locked/unlocked, record retention labels, created date, and author.
**Note. I created a new search result source with the combined condition of RefinableInt02=1 OR RefinableInt03=1 to retrieve all records, both locked and unlocked for the results web part and then added the locked status as a filter:
Combining the power of Search with Records Management is a great way to help site administrators, data stewards, and records managers gain insight on how records are being managed across a site. Let’s help them out.
Thanks for reading.