API How to retrieve state field value

Hey guys, how do I properly retrieve the state field value?

My query:

[{ "command": "fibery.entity/query", 
  "args": { 
    "query": {
      "q/from": "CRM/Person Email Activity",
      "q/select": [
        "fibery/id",
        "fibery/public-id", 
        "CRM/UUID", 
        "workflow/state"
      ],
      "q/where": ["=", ["CRM/UUID"], "$message_id"],
      "q/limit": 1
    },
    "params":{
      "$message_id": "d9a1f3b2-4c7e-4a6f-9b2d-3c8e1f0a5b6c"
    }
  } 
}]

produces an error:


{
"success": 
false,
"result": 
{
"name": 
"entity.error/query-primitive-field-expr-invalid",
"message": 
"Invalid field expression, field: \"workflow/state\" field is not primitive.",
"data": 
{
"top": 
{
"error/name": 
"entity.error/query-primitive-field-expr-invalid",
"field": 
[
"workflow/state"
]
},
"cause": 
{
"error/name": 
"entity.error/query-primitive-field-expr-invalid",
"field": 
[
"workflow/state"
]
},
"field": 
[
"workflow/state"
]
}
}
}
]

Thank you.

The state field is just an example of a select field

Sorry Chris. It’s unclear what you wanted to say.

The workflow field is not a ‘primitive’ field where you query its value, so you need to specify which property - typically its name - that you wish to return. Check out the guide I linked to, and this other topic.

1 Like

Awesome. Exactly what I needed. Strangely I hadn’t found that earlier. Thanks for your help Chris!

Fibery AI is such a time saver especially when it comes to creating API queries.