# Extension 2.0 Screens - How to add filtering

**URL:** <https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621>\
**Category:** Dynatrace Tips\
**Tags:** filter, extensions\
**Created:** [June 28, 2022, 8:28am UTC](https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621 "2022-06-28T08:28:34Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Radu](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radu/32/23351_2.png) [@Radu](https://community.dynatrace.com/u/Radu)\
**Post date:** [June 28, 2022, 8:28am UTC](https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621/1 "2022-06-28T08:28:34Z")

</div>

**Use case** : Enabling filtering and filter bars to [entity lists](https://www.dynatrace.com/support/help/shortlink/ua-pages#entities-list-card) of [screens](https://www.dynatrace.com/support/help/shortlink/ua-pages) created from an [Extension 2.0 YAML](https://www.dynatrace.com/support/help/extend-dynatrace/extensions20/extension-yaml).

 ![Radu_0-1656400972454.png](https://global.discourse-cdn.com/dynatrace/original/3X/b/6/b64710fc6a29ba765b0b1fbc8ffaf38d2eaa874c.png)

**Example context** : I have an entity type “my:interface” that has a RUNS\_ON relationship to an entity type “my:device”. I have an [Entities List card](https://www.dynatrace.com/support/help/shortlink/ua-pages#entities-list-card) which already lists all “my:interface” entities I want to filter.

All definitions are given based on schema version 1.239 and may or may not change in the future.

**Example 1** : I want to filter my list by the interface names.  
YAML definition:

```auto
filtering:
  entityFilters:
    - displayName: Interface
      filters:
        - type: entityName
          displayName: Name
          freeText: true
          modifier: contains
          defaultSearch: true
          distinct: false
          entityTypes:
            - my:interface

```

**YAML explanation** :

- **filtering** - the block which defines the filtering capability
- **entityFilters** - the block which defines the groups of filters (these are displayed slightly greyed out in the filtering list)
- **filters** - the actual filters that are part of this group
  - **displayName** - how this filter is labelled within the UI

  - **type** - must reference an attribute of the entity you are filtering. Note: every entity has **entityName** as a default attribute.

  - **freeText** - if true, the user can freely type text; otherwise they must select from a list of suggestions. Note: only default attributes such as **entityName** are capable of offering list of suggestions.

  - **modifier** - when **freeText** is **true** , this defines how the text should be matched against the attribute. When **freeText** is **false** , this must be omitted. Note: all non-default attributes must match as “equals” regardless of this option.

  - **defaultSearch** - when true, if the user starts typing without selecting a filter first, this filter will be selected by default. Only one filter within the **filtering** block may have this enabled.

  - **distinct** - when true, only one instance of this filter can be applied

  - **entityTypes** - A mandatory list of entity types that this filter applies to. If you omit this, your filtering bar will just show a spinning wheel because of the incomplete definition.

**Example 2** : Given example 1, I also want to filter by the device these interfaces are running on

**YAML definition:**

```auto
filtering:
  relationships:
    - type(my:device),toRelationships.runsOn($(entityConditions))
  entityFilters:
    - displayName: Interface
      filters:
        - type: entityName
          displayName: Name
          freeText: true
          modifier: contains
          defaultSearch: true
          distinct: false
          entityTypes:
            - my:interface
    - displayName: Related entity
      filters:
        - type: entityName
          displayName: Device name
          freeText: false
          defaultSearch: false
          distinct: true
          entityTypes:
            - my:device

```

**YAML Explanation:**

Most of the definition is the same as above. Changes include:

- **filters**
  - **entityTypes** - For the second filter, this is now “my:device”. This is because despite filtering a list of interfaces, the filter attribute belongs to devices.

- **relationships**
  - any entity that is not directly part of the entity list must have a relationship defined to the listed entity for it to be considered. **$(entityConditions)** here resolves to each of the “my:interface” entities.

---

_[View the full topic](https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621)._
