# \[SOLVED\] API entity update status

**URL:** <https://community.fibery.io/t/solved-api-entity-update-status/2778>\
**Category:** API & Programming\
**Created:** [May 9, 2022, 2:04pm UTC](https://community.fibery.io/t/solved-api-entity-update-status/2778 "2022-05-09T14:04:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex\_qi](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@alex\_qi](https://community.fibery.io/u/alex_qi)\
**Post date:** [May 9, 2022, 2:04pm UTC](https://community.fibery.io/t/solved-api-entity-update-status/2778/1 "2022-05-09T14:04:50Z")

</div>

Hello, I fell a little lost in trying to change the workflow status of an entity.  
The workflow is the “default” fibery workflow with Open, In Progress, Done.

With the query below I changed the Name [enum/name] of the whole  
workflow state and not the state of the entity.

db\_sync\_cmd = [  
‘[{’,  
‘“command”:“fibery.entity/update”,’,  
‘“args”:{’,  
‘“type”:“workflow/state\_Projekt Planung/Task”,’,  
‘“entity”:{’,  
f’“fibery/id”:"{fib\_task[“workflow/state”][“fibery/id”]}",’,  
f’“enum/name”:“In Progress”’,  
‘}’,  
‘}’,  
‘}]’,  
]

fib\_task[“workflow/state”][“fibery/id”] =  
ID of the workflow status I got from the query I do initially to get entity information  
{“workflow/state”: [“fibery/id”, “enum/name”]}

---

<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:** [May 9, 2022, 2:16pm UTC](https://community.fibery.io/t/solved-api-entity-update-status/2778/2 "2022-05-09T14:16:39Z")

</div>

Instead of updating the workflow entity, you should be updating the workflow field for the entity whose status you wish to change.

Something like this:

```auto
await fibery.entity.updateBatch([
  {
    'type': 'Projekt Planung/Task',
    'entity': {
      'fibery/id': '20f9b920-9752-11e9-81b9-4363f716f666',
      'workflow/state': { 'fibery/id': 'd328b7b0-97fa-11e9-81b9-4363f716f666' }
    }
  }
]);

```

You’ll need to know the IDs of the entity and the In Progress state option

---

<div class="post-metadata">

**Author:** ![alex\_qi](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@alex\_qi](https://community.fibery.io/u/alex_qi)\
**Post date:** [May 9, 2022, 2:22pm UTC](https://community.fibery.io/t/solved-api-entity-update-status/2778/3 "2022-05-09T14:22:58Z")

</div>

Thank you very much for the fast and helpful answer!!!

The ID for each state will be them same for all entities I assume?  
So one ID for Done, one for In Progress…

So I just need to get them once

---

<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:** [May 9, 2022, 2:24pm UTC](https://community.fibery.io/t/solved-api-entity-update-status/2778/4 "2022-05-09T14:24:03Z")

</div>

Yes, correct

---

<div class="post-metadata">

**Author:** ![alex\_qi](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@alex\_qi](https://community.fibery.io/u/alex_qi)\
**Post date:** [May 9, 2022, 2:25pm UTC](https://community.fibery.io/t/solved-api-entity-update-status/2778/5 "2022-05-09T14:25:31Z")

</div>

Your the best!!! 🙂  
Thanks

---

<div class="post-metadata">

**Author:** ![IMTanuki](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/imtanuki/32/7751_2.png) [@IMTanuki](https://community.fibery.io/u/IMTanuki)\
**Post date:** [April 16, 2024, 9:13pm UTC](https://community.fibery.io/t/solved-api-entity-update-status/2778/6 "2024-04-16T21:13:33Z")

</div>

@Chr1sG - can I ask - what is the name of the workflow entity and what is its structure? I assume the only way to obtain this is in js by reading the workflow entity and building an array …

---

<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:** [April 17, 2024, 6:25am UTC](https://community.fibery.io/t/solved-api-entity-update-status/2778/7 "2024-04-17T06:25:46Z")

</div>

> [@IMTanuki](#):
>
> what is the name of the workflow entity and what is its structure?

Workflow is itself a database, but a ‘hidden’ one.  
It has fields like any other db (Name, Creation Date etc.) and has a relation to its owning type.  
In the schema, the name of the workflow type is typically something like this:  
`workflow/state_SpaceName/OwningType`  
The workflow options are entities in this database, so you can query them just like any other entity in the workspace.

> [@IMTanuki](#):
>
> I assume the only way to obtain this is in js by reading the workflow entity and building an array

Not sure what the ‘this’ you want to obtain is? If you want to read the value of state, it is available when you read the entity, e.g. if you execute this:

```auto
const fibery = context.getService('fibery');

for (const entity of args.currentEntities) {
    console.log(entity);
}

```

the output might look like this:

```auto
{
  'Created By': { Name: 'chris', Id: 'e6e65d48-ed1d-405e-ad2f-6493278c39b7' },
  'Public Id': '1',
  Id: '73db52b9-7a34-4deb-8078-f92ebc4efbf1',
  'Creation Date': '2024-03-29T11:47:14.635Z',
  'Modification Date': '2024-04-17T06:14:28.699Z',
  Rank: 8672589213253628,
  Name: 'Do this',
  State: { Id: 'be143480-fc81-11ee-8995-d94ed8550e07', Name: 'To Do' },
  Type: 'Project/Task'
}

```

If you need to know all possible values, then the easiest way to do it is to write a graphql query.
