---
title: Configure custom contact field empty values
related:
  - https://docs.kentico.com/documentation/business-users/digital-marketing/contact-groups.md
  - https://docs.kentico.com/documentation/business-users/digital-marketing/automation.md
  - https://docs.kentico.com/documentation/developers-and-admins/customization/field-editor/add-custom-data-types.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

If you have [custom contact fields](https://docs.kentico.com/documentation/developers-and-admins/digital-marketing-setup/contact-configuration.md#add-custom-fields-to-contacts) that use a [custom data type](https://docs.kentico.com/documentation/developers-and-admins/customization/field-editor/add-custom-data-types.md) and wish to use these fields with the _Contact field value is empty_ condition in [contact groups](https://docs.kentico.com/documentation/business-users/digital-marketing/contact-groups.md) or [automation processes](https://docs.kentico.com/documentation/business-users/digital-marketing/automation.md#rule-based-conditions), you need to define what value is considered as empty for the data type. Otherwise the condition will not be evaluated correctly. You can configure the empty value for individual data types by extending the `ContactFieldEmptyValueProvider` using the [decorator pattern](https://docs.kentico.com/documentation/developers-and-admins/customization/decorate-system-services.md). Additionally, you can change the empty values provided by the system for the default contact fields.

## Define custom empty values

1. Open your solution in Visual Studio.
2. [Add a custom assembly](https://docs.kentico.com/documentation/developers-and-admins/customization/integrate-custom-code.md) (_Class Library_ project) with class discovery enabled to the solution, or re-use an existing assembly.
3. Reference the project from your Xperience website project.

Continue by implementing the custom class:

1. Create a new custom class. For example, name the class `CustomContactFieldEmptyValueProvider`.
2. Make the class implement the `IContactFieldEmptyValueProvider` interface.
3. Add the `Get` method:
   - Use the [decorator customization pattern](https://docs.kentico.com/documentation/developers-and-admins/customization/decorate-system-services.md#decorate-services-via-dependency-injection) to call the default implementation of the `Get` method. This call returns a dictionary which maps the system data types to their empty value. Here, you can add the empty values of your custom data types or adjust the empty values of the system data types.
4. Register the implementation using the `RegisterImplementation` assembly attribute.

```csharp title=""
using CMS;
using CMS.ContactManagement;
using CMS.DataEngine;

[assembly: RegisterImplementation(typeof(IContactFieldEmptyValueProvider), typeof(CustomContactFieldEmptyValueProvider))]


public class CustomContactFieldEmptyValueProvider : IContactFieldEmptyValueProvider
{
    // Stores the default implementation of the IContactFieldEmptyValueProvider service
    private readonly IContactFieldEmptyValueProvider contactFieldEmptyValueProvider;

    // Stores the empty string value as an object array
    private static readonly object[] emptyString = { "" };

    public CustomContactFieldEmptyValueProvider(IContactFieldEmptyValueProvider contactFieldEmptyValueProvider)
    {
        this.contactFieldEmptyValueProvider = contactFieldEmptyValueProvider;
    }

    // Allows you to make adjustments to the empty value dictionary
    public Dictionary<string, object[]> Get()
    {
        // Calls the default IContactFieldEmptyValueProvider.Get implementation
        var result = contactFieldEmptyValueProvider.Get();

        // Sets a custom empty value for the custom data type with the "mydatatype" identifier
        result.Add("mydatatype", emptyString);

        // You can also rewrite the default empty values provided in the dictionary
        // Access the identifiers of the system data types via constants in the FieldDataType class
        result[FieldDataType.Text] = emptyString;

        return result;
    }
}
```
