# Why is \`entity\['Name'\]\` get \`null\`?

**URL:** <https://community.fibery.io/t/why-is-entity-name-get-null/4711>\
**Category:** API & Programming\
**Created:** [July 3, 2023, 9:05am UTC](https://community.fibery.io/t/why-is-entity-name-get-null/4711 "2023-07-03T09:05:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ooker](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/ooker/32/7033_2.png) [@Ooker](https://community.fibery.io/u/Ooker)\
**Post date:** [July 3, 2023, 9:05am UTC](https://community.fibery.io/t/why-is-entity-name-get-null/4711/1 "2023-07-03T09:05:02Z")

</div>

# Script 1

```js
const fibery = context.getService('fibery');
console.log(args.currentEntities)
for (const entity of args.currentEntities) {
    const name = entity['Name'];
    const creationDate = entity['Creation Date'];

    console.log("Name: ", name);
    console.log("Creation Date: ", creationDate)
}

```

Result:

```auto
[
  {
    'Created By': { Name: 'ganuongphap', Id: '7b4f2510-dc1f-4b19-b6ff-a790b4ff3565' },
    'Public Id': '23',
    Id: '5bd925d0-1980-11ee-ad19-ab4956e8c55f',
    'Creation Date': '2023-07-03T09:02:51.087Z',
    Test: null,
    'Modification Date': '2023-07-03T09:02:51.087Z',
    Rank: 7712584211451303,
    Name: null,
    Type: 'Customer Feedback/Conversation'
  }
]

Name: null

Creation Date: 2023-07-03T08:43:03.526Z

```

# Script 2

I try using this script to [get all field values for an entity](https://community.fibery.io/t/getting-all-field-values-for-an-entity/2801 "Getting all field values for an entity - API & Programming - Fibery Community"), `name` is still `null`:

```js
const fibery = context.getService('fibery');
// get entire schema
const schema = await fibery.getSchema();
// get specific database (type) name
const typeName = args.currentEntities[0].type;
// filter the schema for the specific type and get all field names
const fields = schema['typeObjects'].filter((obj) => obj.name == typeName)[0]['fieldObjects'].map((field) => field.name);
// get all entities with all fields
const entitiesWithAllFields = await fibery.getEntitiesByIds(typeName, args.currentEntities.map((entity) => entity.id), fields);
// send result to the browser console
console.log(entitiesWithAllFields);

```

Result:

```js
[
  {
    'Customer Feedback/name': null,
    'fibery/modification-date': '2023-07-03T09:01:55.934Z',
    'Collaboration~Documents/References': [],
    'fibery/id': '3afa8930-1980-11ee-ad19-ab4956e8c55f',
    Id: '3afa8930-1980-11ee-ad19-ab4956e8c55f',
    'fibery/created-by': { Name: 'ganuongphap', Id: '7b4f2510-dc1f-4b19-b6ff-a790b4ff3565' },
    'fibery/creation-date': '2023-07-03T09:01:55.934Z',
    'Customer Feedback/Test': null,
    'fibery/public-id': '22',
    'fibery/rank': 7712584210451303
  }
]

```

Any idea why is that? I expect it to return `TEST NAME` here. I want to do some automation based on the value of the field here.

 ![](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/9/9dde7b72babe35580d08480bb200c73e123fd485.png)

---

<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:** [July 3, 2023, 9:18am UTC](https://community.fibery.io/t/why-is-entity-name-get-null/4711/2 "2023-07-03T09:18:27Z")

</div>

How are you running these scripts?

---

<div class="post-metadata">

**Author:** ![Ooker](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/ooker/32/7033_2.png) [@Ooker](https://community.fibery.io/u/Ooker)\
**Post date:** [July 3, 2023, 12:36pm UTC](https://community.fibery.io/t/why-is-entity-name-get-null/4711/3 "2023-07-03T12:36:49Z")

</div>

I save the script, add a new entry, then check the activity tab of the script. Does that answer the question?

I make `Duplicate name` field with formula `Name`. `entity[‘Duplicate name’]` still get `null`.

---

<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:** [July 3, 2023, 2:49pm UTC](https://community.fibery.io/t/why-is-entity-name-get-null/4711/4 "2023-07-03T14:49:27Z")

</div>

So the automation is being triggered on entity creation?  
It sounds like when the entity is being created, the name not yet defined, and then subsequently the name is being provided.

Can you confirm how you are creating a new entity.

---

<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:** [July 3, 2023, 2:50pm UTC](https://community.fibery.io/t/why-is-entity-name-get-null/4711/5 "2023-07-03T14:50:29Z")

</div>

> [@Ooker](#):
>
> I make `Duplicate name` field with formula `Name`. `entity[‘Duplicate name’]` still get `null`.

Formulas are calculated asynchronously, so will typically not have a value at the time the entity is created.

---

<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 3, 2023, 3:43pm UTC](https://community.fibery.io/t/why-is-entity-name-get-null/4711/6 "2023-07-03T15:43:57Z")

</div>

> [@Chr1sG](#):
>
> Formulas are calculated asynchronously, so will typically not have a value at the time the entity is created.

**Related:** [Need an Action to force “Execute/commit previous Actions before continuing”](https://community.fibery.io/t/need-an-action-to-force-execute-commit-previous-actions-before-continuing/3083)

---

<div class="post-metadata">

**Author:** ![Ooker](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/ooker/32/7033_2.png) [@Ooker](https://community.fibery.io/u/Ooker)\
**Post date:** [July 3, 2023, 3:46pm UTC](https://community.fibery.io/t/why-is-entity-name-get-null/4711/7 "2023-07-03T15:46:30Z")

</div>

> [@Chr1sG](#):
>
> Can you confirm how you are creating a new entity.

![](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/c/cf2f847bce773cf73714841d748f306a492b44da.gif)

---

<div class="post-metadata">

**Author:** ![Ooker](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/ooker/32/7033_2.png) [@Ooker](https://community.fibery.io/u/Ooker)\
**Post date:** [July 4, 2023, 4:55am UTC](https://community.fibery.io/t/why-is-entity-name-get-null/4711/8 "2023-07-04T04:55:44Z")

</div>

I change to updated and it’s good now

 ![](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/2/28e7056f03be45e329a08f743ff6a1a7cfe0c8be.png)

---

<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:** [July 4, 2023, 8:14am UTC](https://community.fibery.io/t/why-is-entity-name-get-null/4711/9 "2023-07-04T08:14:33Z")

</div>

Note: you can actually use both triggers (created and updated) in the same automation if that’s appropriate.
