Is the custom Sitecore field type being used?

Took over a 18 year old sitecore solution, which had a number of custom field types and before upgrading to Sitecore 10 of course we wanted to remove any unused functionality.

Unfortunately the customer had no idea if the field types where being used as there are over 900+ sites.

Problem

How to determine if a custom field type is in use?

I thought it would be easy using the link database, the search box in the shell and or the search in content editor.

Unfortunately when I searched for the ID of the field type I found nothing.

I assumed it was because the field type is defined in the core database and used in the master database.

Solution

Therefore it was time to look into the SQL database, to try and determine if the custom fields where in use.

First step was to determine how sitecore knows the field type for a field? I hoped there was a field type column on the following tables that are responsible for storing field values.

  • SharedFields
  • VersionedFields
  • UnversionedFields

Unfortunately sitecore does not save the field type in the SQL database as a dedicated column, in fact they store the type like any other field, as a value on the field.

The field responsible for storing what type of field a field is, is the the Type field from the Template Field template. See the image below, notice the source field is set to get values from the core database.

The Type field id is “{AB162CC0-DC80-4ABF-8871-998EE5D7BA32}” and as you can see in the image below we can then restrict our search to fields values of that field.

This is when I discovered that the value stored for the field is not the Guid of the field type, but the name :-(.

So the following SQL can be used to search for any field type and determine if the field is used.

The ItemId is the Id of the field which uses the custom field type.

SELECT *
  FROM [dtu_master_upgrade].[dbo].[SharedFields] 
    where FieldId = 'AB162CC0-DC80-4ABF-8871-998EE5D7BA32' and 
          Value like '%[NAME OF CUSTOM FIELD TYPE]%'

SELECT *
  FROM [dtu_master_upgrade].[dbo].[UnversionedFields] 
    where FieldId = 'AB162CC0-DC80-4ABF-8871-998EE5D7BA32' and 
          Value like '%[NAME OF CUSTOM FIELD TYPE]%'

SELECT *
  FROM [dtu_master_upgrade].[dbo].[VersionedFields] 
    where FieldId = 'AB162CC0-DC80-4ABF-8871-998EE5D7BA32' and 
          Value like '%[NAME OF CUSTOM FIELD TYPE]%'

From the field you can get the template and you can then check if the template is being used, by using the Links button on the Navigate Menu, see below.

Hope this helps, Alan

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

This site uses Akismet to reduce spam. Learn how your comment data is processed.