# fibery.createEntity() creates the entity without the specified fields?

**URL:** <https://community.fibery.io/t/fibery-createentity-creates-the-entity-without-the-specified-fields/4817>\
**Category:** Bugs & Issues\
**Tags:** automations\
**Created:** [July 19, 2023, 8:45pm UTC](https://community.fibery.io/t/fibery-createentity-creates-the-entity-without-the-specified-fields/4817 "2023-07-19T20:45:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [July 19, 2023, 8:45pm UTC](https://community.fibery.io/t/fibery-createentity-creates-the-entity-without-the-specified-fields/4817/1 "2023-07-19T20:45:56Z")

</div>

It _appears_ that `fibery.createEntity()` creates a new entity initially _without_ the specified fields content, and then after some time the entity is updated with the fields content specified in `createEntity`.

I say this because I have a script that does this:

```auto
fibery.createEntity( 'Page', {Name, 'Is Template': true} )

```

I have a separate Rule that triggers when a new Page entity is created – but this Rule has a filter which _should_ prevent it from triggering in this case, because in this case the entity is being created with `{'Is Template': true}` –

> ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/0/04f1b2240f7d9055f0eb98d62b74683d9e4a066e.png)

And yet, this Rule **runs immediately** after the other script creates a new Page entity, which implies that the fields specified in `fibery.createEntity()` were not yet set… because if they had been set, the Rule’s filter should have prevented it from running. 🤔

Or am I missing something?

This would be quite inconvenient, because It would mean that a Rule triggering on “entity created” cannot distinguish whether an entity _is still being created_ – its filters are useless.

---

<div class="post-metadata">

**Author:** ![Sergey\_Truhtanov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/sergey_truhtanov/32/13986_2.png) [@Sergey\_Truhtanov](https://community.fibery.io/u/Sergey_Truhtanov)\
**Post date:** [July 20, 2023, 2:38pm UTC](https://community.fibery.io/t/fibery-createentity-creates-the-entity-without-the-specified-fields/4817/2 "2023-07-20T14:38:16Z")

</div>

Hello.

That should not be the case. `fibery.createEntity` works just like you’ve described, creating entity with all the fields at once.

Could you please share more info: workspace name, both rules that cause the issue (names will be enough) and entity for which this setup _did not work_ correctly(“public id” would be good).

---

<div class="post-metadata">

**Author:** ![Sergey\_Truhtanov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/sergey_truhtanov/32/13986_2.png) [@Sergey\_Truhtanov](https://community.fibery.io/u/Sergey_Truhtanov)\
**Post date:** [July 20, 2023, 3:18pm UTC](https://community.fibery.io/t/fibery-createentity-creates-the-entity-without-the-specified-fields/4817/3 "2023-07-20T15:18:14Z")

</div>

Btw, I’ve checked similar setup on my account, and filter works as expected.

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [July 20, 2023, 4:33pm UTC](https://community.fibery.io/t/fibery-createentity-creates-the-entity-without-the-specified-fields/4817/4 "2023-07-20T16:33:56Z")

</div>

Info sent in Private Message.

---

<div class="post-metadata">

**Author:** ![Sergey\_Truhtanov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/sergey_truhtanov/32/13986_2.png) [@Sergey\_Truhtanov](https://community.fibery.io/u/Sergey_Truhtanov)\
**Post date:** [July 21, 2023, 10:00am UTC](https://community.fibery.io/t/fibery-createentity-creates-the-entity-without-the-specified-fields/4817/5 "2023-07-21T10:00:11Z")

</div>

Dig into details and here is an explanation(just sharing it for everybody):

Filter in Automation Rules do not run on a state at the moment of a change, that caused Rule’s trigger. Instead, they run on a live state at the moment of a Rule run. So there is a delay.  
First your script performs a change.  
Then some time passes and Rule Engine receives an event about this change.  
At that moment Rule Engine performs query to Fibery Api to check if Entity corresponds to a Filter.  
This query is performed on a live data, and Entity may be changed in time interval from the change and to time when event is processing by a Rule Engine.

We don’t proud of this behavior, but consider it as a compromise, as we wanted to support powerful Filters for Automation Rules. We didn’t get much complains on this behavior over years, so at the moment we stick with it.

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [July 21, 2023, 4:00pm UTC](https://community.fibery.io/t/fibery-createentity-creates-the-entity-without-the-specified-fields/4817/6 "2023-07-21T16:00:29Z")

</div>

Thanks @Sergey_Truhtanov.

This essentially means that we cannot reliably use filters on an “entity created” Rule _to distinguish whether a new entity has been modified since its creation._

Other processes (including the one creating a new entity) can modify a new entity _before_ a “when created” Rule is triggered for it.

> This actually makes sense, because you could have many Rules that trigger on “entity created” for a DB, and they can’t ALL be first. 😂

My workaround is to add a new field to the DB, to help Rules know which entities to ignore.

For example in my cloneable DBs I added a Text field called “Rules”. When my cloner script creates a new entity, it puts the string “[CLONE]” in this field. This can then be detected by the other Rules which run on entity creation with the filter: `[Rules] contains "[CLONE]"` (or the inverse, to avoid processing cloned entities).
