# Feature SSI-178 - Global search finds values of custom fields of type hierarchy

Project: Stream Storage Integrations
Status: in specification
URL: https://community.openproject.org/work_packages/SSI-178

## Planning

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Target versions | Wish List |
| Votes |  |
| List |  |
| Roadmap |  |
| Relevance |  |

## OPEN POINTS / FEEDBACK

_No work packages_

## Features and Chunks

_No work packages_

## Bugs and other work packages

_No work packages_

## Technical Details

| Attribute | Value |
| --- | --- |
| Module |  |
| Feature Flag |  |
| Requires doc change | No |
| Enterprise plan |  |

## Details

| Attribute | Value |
| --- | --- |
| Pull preview |  |
| Mockups |  |
| Accessibility | No |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| PD (min) |  |
| PD (max) |  |
| Work |  |
| Labor costs |  |

## Description

**As a** user  
**I want to** be able to search for item labels of a custom field hierarchy  
**so that** I can find work packages which have a value assigned matching the search term.

**Acceptance Criteria**

*   If a text is searched globally, the search result must contain work packages, that have a value assigned to a custom field of type hierarchy where the search term matches the following expectations:
    
    *   the search term is a substring of the item label
        
    *   the search term is a substring of any ancestor label on the branch of the item
        
    *   the search term is a substring of the item short
        

### Information

*   the custom values of custom fields of type list do have special handling in `act_as_searchable.rb`
    

```ruby
def build_custom_field_condition(custom_field_ids)
  CustomValue.select("1")
    .joins(<<~SQL.squish)
      LEFT JOIN custom_options
      ON custom_options.custom_field_id = custom_values.custom_field_id
      AND custom_options.id::VARCHAR = custom_values.value
    SQL
    .where(customized_type: name, custom_field_id: custom_field_ids)
    .where("customized_id=#{table_name}.id")
    .where("(custom_values.value ILIKE ?) OR (custom_options.value ILIKE ?)")
end
```

*   usually this kind of code should go into responsibility of the custom field itself
