# Query where field is Enum value

**URL:** <https://community.fibery.io/t/query-where-field-is-enum-value/2491>\
**Category:** API & Programming\
**Created:** [February 4, 2022, 2:44pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491 "2022-02-04T14:44:10Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![NWE](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/nwe/32/4696_2.png) [@NWE](https://community.fibery.io/u/NWE)\
**Post date:** [February 4, 2022, 2:44pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491/1 "2022-02-04T14:44:10Z")

</div>

Hello, I’m new to Fibery and lack programming skills but I’m setting up a scenario through Integromat that’s supposed to update a enum field based on various things outside of Fibery.

When doing it through Integromat you need to send the fiberyID for the enum, when hardcoding it it works fine but since the enum is 34 different options I need to send the FiberyID

Example:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/d/d3ac90dc2a981bd710b41d845217b0932eca51cd.png)  
equals  
5d91fa30-77d5-11ec-873c-79fed3408808

So i figured I could do an API request to search for the specific enum ID and pass it to update later on, but running into issues when doing the query for enum value

This request works fine because FDFilial is just a text field.

[  
{  
“command”: “fibery.entity/query”,  
“args”: {  
“query”: {  
“q/from”: “EBB-Database/DatabaseEBB”,  
“q/select”: [  
“fibery/id”,  
{  
“EBB-Database/Filial”: [  
“fibery/id”,  
“enum/name”  
]  
}  
],  
“q/where”: [  
“=”,  
[  
“EBB-Database/IMEI”  
],  
“$search”  
],  
“q/limit”: 1  
},  
“params”: {  
“$search”: “357010078609011”  
}  
}  
}  
]

But when trying to search for ‘Filial’ (which is a enum field) with the request

[  
{  
“command”: “fibery.entity/query”,  
“args”: {  
“query”: {  
“q/from”: “EBB-Database/DatabaseEBB”,  
“q/select”: [  
“fibery/id”,  
{  
“EBB-Database/Filial”: [  
“fibery/id”,  
“enum/name”  
]  
}  
],  
“q/where”: [  
“=”,  
[  
“EBB-Database/Filial”  
],  
“$search”  
],  
“q/limit”: 1  
},  
“params”: {  
“$search”: “013”  
}  
}  
}  
]

I get

{  
“success”: false,  
“result”: {  
“name”: “entity.error/query-func-expr-type-invalid”,  
“message”: “Invalid query func expression database q/field-secured-access?, q/in, fibery/acl, fibery/access-group, fibery/id, $fibery/user-group-ids, EBB-Database/Filial, {“param-var”:”$anon-param17",“param-type”:“fibery/nil”}."

So what am I doing wrong?

Any help would be grateful  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [February 4, 2022, 2:55pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491/2 "2022-02-04T14:55:18Z")

</div>

The enum field is actually a type of its own behind-the-scenes. So to get the id of an enum, you need to query the enum database.  
The enum database name will be something like `${app}/${field}_${app}/${holder-type}`  
where field is the enum field name and holder-type is the name of the database.

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [February 4, 2022, 2:56pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491/3 "2022-02-04T14:56:37Z")

</div>

By the way, you wrote

> [@NWE](#):
>
> This request works fine because FDFilial is just a text field.

but perhaps you meant  
“This request works fine because IMEI is just a text field.” ?

---

<div class="post-metadata">

**Author:** ![NWE](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/nwe/32/4696_2.png) [@NWE](https://community.fibery.io/u/NWE)\
**Post date:** [February 4, 2022, 2:59pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491/4 "2022-02-04T14:59:23Z")

</div>

Yeah, you are correct, I had so many tabs up I mixed it up but the result is the same.

I guess I must have missed that enum type is it’s own database, I will try to make your solution work with.

${app}/${field}\_${app}/${holder-type}

Thank you!

---

<div class="post-metadata">

**Author:** ![NWE](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/nwe/32/4696_2.png) [@NWE](https://community.fibery.io/u/NWE)\
**Post date:** [February 4, 2022, 4:23pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491/5 "2022-02-04T16:23:54Z")

</div>

Hm, not really getting this to work

I have a few enum fields and when trying this post

```auto
[
         {
           "command": "fibery.entity/query",
           "args": {
             "query": {
               "q/from": "EBB-Database/Filial_EBB-Database/DatabaseEBB",
               "q/select": [
                 "EBB-DataBase/Filial"
               ],
               "q/limit": 1
             }
           }
         }
       ]

```

I get

```auto
"message": "Invalid query.\nCause: EBB-Database/Filial_EBB-Database/DatabaseEBB database was not found."

```

So seems like it can’t find the database, but when trying another field

```auto
[
         {
           "command": "fibery.entity/query",
           "args": {
             "query": {
               "q/from": "EBB-Database/DeploymentStatus_EBB-Database/DatabaseEBB",
               "q/select": [
                 "EBB-DataBase/DeployementStatus"
               ],
               "q/limit": 1
             }
           }
         }
       ]

```

I get

```auto
"message": "Invalid query.\nCause: EBB-DataBase/DeployementStatus field was not found in EBB-Database/DeploymentStatus_EBB-Database/DatabaseEBB database."

```

I’m definitely doing something wrong but it seems it doesn’t find the database at all, but the second post it finds the database but not the correct field?  
Even though both ‘Filial’ and ‘DeploymentStatus’ is in the same database.

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [February 4, 2022, 4:28pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491/6 "2022-02-04T16:28:46Z")

</div>

It looks like the latter has a spelling mistake:

EBB-DataBase/Deploy **e** mentStatus

unless I’m mistaken.  
Not sure what might be the problem with the former.

Perhaps you could post a screen grab of all the fields in your database.  
Alternatively. you can use the getSchema() api call to find the names of all the databases and fields etc.

---

<div class="post-metadata">

**Author:** ![NWE](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/nwe/32/4696_2.png) [@NWE](https://community.fibery.io/u/NWE)\
**Post date:** [February 4, 2022, 4:51pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491/7 "2022-02-04T16:51:42Z")

</div>

The spelling mistake was indeed there but same result with correcting it.

I did a get schema call and for some reason it’s named Filial\_New Space while other fields are not

```auto
{
                            "fibery/name": "EBB-Database/Filial",
                            "fibery/type": "EBB-Database/Filial_New Space/DatabaseEBB",
                            "fibery/deleted?": false,
                            "fibery/meta": {
                                "ui/object-editor-order": 0,
                                "fibery/type-component?": true,
                                "fibery/relation": "84e062c0-77d5-11ec-9234-4d6c82e7b87f",
                                "fibery/secured?": true,
                                "fibery/required?": false,
                                "ui/type-editor-order": 4,
                                "fibery/entity-of-field-type-can-be-created-by-creator-only?": true
                            }

```

 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/5/53676e824f861fd34d7b02c5465cb6a87002b4cc.png)

I kind of confused myself now but unsure what I should put in the call to find enum IDs

```auto
[
  {
    "command": "fibery.entity/query",
    "args": {
      "query": {
        "q/from": "EBB-Database/Filial_New Space/DatabaseEBB",
        "q/select": [
          "fibery/id",
          { "EBB-Database/Filial_New Space": ["fibery/id","enum/name"] }
        ],
        "q/where": [
          "=",
          [
            "EBB-Database/Filial_New Space"
          ],
          "$search"
        ],
        "q/limit": 1
      },
      "params": {
        "$search": "013"
      }
    }
  }
]

```

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [February 4, 2022, 5:13pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491/8 "2022-02-04T17:13:32Z")

</div>

I’ll get one of the devs to join this chat, since I’m not an API expert, but I think you might need to use the following

```auto
[
  {
    "command": "fibery.entity/query",
    "args": {
      "query": {
        "q/from": "EBB-Database/Filial_New Space/DatabaseEBB",
        "q/select": [
          "fibery/id",
          "enum/name"
        ],
        "q/where": [
          "=",
          [
            "enum/name"
          ],
          "$search"
        ],
        "q/limit": 1
      },
      "params": {
        "$search": "013"
      }
    }
  }
]

```

---

<div class="post-metadata">

**Author:** ![NWE](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/nwe/32/4696_2.png) [@NWE](https://community.fibery.io/u/NWE)\
**Post date:** [February 4, 2022, 5:19pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491/9 "2022-02-04T17:19:48Z")

</div>

Cheers to adding someone in, and thank you for the patience .

I tried the call and got

```auto
[
    {
        "success": false,
        "result": {
            "name": "entity.error/query.invalid",
            "message": "Invalid query.\nCause: 'EBB-Database/Filial_New Space' field was not found in 'EBB-Database/Filial_New Space/DatabaseEBB' database.",
            "data": {
                "top": {
                    "error/name": "entity.error/query.invalid",
                    "errors": [
                        {
                            "error/name": "entity.error/schema-field-not-found",
                            "field": "EBB-Database/Filial_New Space",
                            "type": "EBB-Database/Filial_New Space/DatabaseEBB"
                        }
                    ]

```

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [February 4, 2022, 5:25pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491/10 "2022-02-04T17:25:40Z")

</div>

Sorry, I made a mistake, but have now edited my previous response. Can you try again.

---

<div class="post-metadata">

**Author:** ![NWE](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/nwe/32/4696_2.png) [@NWE](https://community.fibery.io/u/NWE)\
**Post date:** [February 4, 2022, 5:34pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491/11 "2022-02-04T17:34:06Z")

</div>

Oh wow, cheers.

Really, thanks a lot for the time and the help!

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [February 4, 2022, 5:37pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491/12 "2022-02-04T17:37:17Z")

</div>

So I assume that means you got it working… 👍

---

<div class="post-metadata">

**Author:** ![NWE](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/nwe/32/4696_2.png) [@NWE](https://community.fibery.io/u/NWE)\
**Post date:** [February 4, 2022, 5:38pm UTC](https://community.fibery.io/t/query-where-field-is-enum-value/2491/13 "2022-02-04T17:38:23Z")

</div>

Yeah indeed, I marked it as the solution if anyone else is having issues.

Thanks again.
