# Dataservice TextOption field

**URL:** <https://forum.litium.com/t/dataservice-textoption-field/1742>\
**Category:** Questions\
**Tags:** litium-7\
**Created:** [November 5, 2020, 4:48pm UTC](https://forum.litium.com/t/dataservice-textoption-field/1742 "2020-11-05T16:48:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aram](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/aram/32/19_2.png) [@aram](https://forum.litium.com/u/aram)\
**Post date:** [November 5, 2020, 4:48pm UTC](https://forum.litium.com/t/dataservice-textoption-field/1742/1 "2020-11-05T16:48:58Z")

</div>

**Scenario** :  
In the current solution I am working with we have implemented a custom approval process. an order should be approved by 2 authorizers and we assign each customer with 2 specific authorizers by setting them in 2 different **TextOption** fields.

When we delete an authorizer from the system we need to fetch all persons and removed the deleted authorizer from the field. So I have implemted a event listener that listens to PersonDeleted and the I use dataService to fetch the customers that had the deleted person as authorizer assigned to it.

**Problem** :  
When I execute my dataService I get the following exception:  
`No field with id 'Authorizer1' and operator 'eq'.`

Isn’t it possible to search for persons by TextOption-field? In this case how can I solve it?

My **implementation** of the dataService:

```
    List<Person> GetPersonsByFieldValue(string fieldId, string fieldValue)
    {
        using (var query = _dataService.CreateQuery<Person>())
        {
            var q = query.Filter(f =>
                f.Bool(boolFilter => boolFilter
                    .Must(must =>
                        must.Field(fieldId, "eq", fieldValue))
                ));

            return q.ToList();
        }
    }

```

Litium version: _[7.4.2]_

---

<div class="post-metadata">

**Author:** ![utku](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/utku/32/62_2.png) [@utku](https://forum.litium.com/u/utku)\
**Post date:** [November 6, 2020, 11:39am UTC](https://forum.litium.com/t/dataservice-textoption-field/1742/3 "2020-11-06T11:39:08Z")

</div>

Hi,  
Did you check which operators are avialable for TextOption field? See the opretor check example at [https://docs.litium.com/documentation/architecture/data-service](https://docs.litium.com/documentation/architecture/data-service)

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [November 6, 2020, 12:43pm UTC](https://forum.litium.com/t/dataservice-textoption-field/1742/4 "2020-11-06T12:43:00Z")

</div>

Why don’t you use Boolean fields instead?  
If you are creating 2 new fields (Authorizer1 and Authorizer2) then a true/false value on each item should fulfill that purpose or am I missing something?

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [November 6, 2020, 2:05pm UTC](https://forum.litium.com/t/dataservice-textoption-field/1742/5 "2020-11-06T14:05:24Z")

</div>

This would give you what you need:

```auto
List<Person> GetPersonsByFieldValue(string fieldId, string fieldValue)
        {
            using (var query = _dataService.CreateQuery<Person>())
            {
                var q = query.Filter(f => f.Field(fieldId, "contains", fieldValue));
                return q?.ToList();
            }
        }

```

---

<div class="post-metadata">

**Author:** ![aram](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/aram/32/19_2.png) [@aram](https://forum.litium.com/u/aram)\
**Post date:** [November 9, 2020, 10:43am UTC](https://forum.litium.com/t/dataservice-textoption-field/1742/6 "2020-11-09T10:43:36Z")

</div>

Thanks @steve.redstorm. Used your suggestion and added an additional condition on the result to achieve the result of an “eq”-operator.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [December 7, 2020, 10:43am UTC](https://forum.litium.com/t/dataservice-textoption-field/1742/7 "2020-12-07T10:43:42Z")

</div>

Closed on December 7, 2020, 10:43am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
