# Help automatically adding list of related entities to a rich-text field/document

**URL:** <https://community.fibery.io/t/help-automatically-adding-list-of-related-entities-to-a-rich-text-field-document/5971>\
**Category:** Get Help\
**Created:** [March 13, 2024, 1:38pm UTC](https://community.fibery.io/t/help-automatically-adding-list-of-related-entities-to-a-rich-text-field-document/5971 "2024-03-13T13:38:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![interr0bangr](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/interr0bangr/32/8089_2.png) [@interr0bangr](https://community.fibery.io/u/interr0bangr)\
**Post date:** [March 13, 2024, 1:38pm UTC](https://community.fibery.io/t/help-automatically-adding-list-of-related-entities-to-a-rich-text-field-document/5971/1 "2024-03-13T13:38:01Z")

</div>

I’m trying to use the example given in Fibery’s markdown documentation [here](https://the.fibery.io/@public/User_Guide/Guide/Markdown-Templates-53/anchor=Mentioning-Entities-and-Users--92511af3-219c-4cf8-be03-dec1a717cdf2) to create a list of all the related entities inside of a rich text field.

When I modify the example script with my database names and try to run it, I get an error.

Here’s the example script:

```auto
{!Books:Id!}
<%
const fibery = context.getService('fibery');
const schema = await fibery.getSchema();
const dbID = schema['typeObjects'].filter((obj) => obj.name == 'Strategy/Book')[0]['id'];
%>
<%= Entity.Books.map((book) => "[[#^" + dbID + "/" + book.Id + "]]").join('\n') %>

```

and here’s my modified version:

```auto
{!Leads:Id!}
<%
const fibery = context.getService('fibery');
const schema = await fibery.getSchema();
const dbID = schema['typeObjects'].filter((obj) => obj.name == 'Test Environment/Lead')[0]['id'];
%>
<%= Entity.Leads.map((lead) => "[[#^" + dbID + "/" + lead.Id + "]]").join('\n') %>

```

and here’s the error:

```auto
Failed to execute Action "Overwrite Description": Cannot read property 'id' of undefined

```

It seems like the object name is undefined.  
I assumed in the example the space was “Strategy” and the database was “Book”, which is the same way mine is structured, is that not actually the case?

---

<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:** [March 13, 2024, 4:57pm UTC](https://community.fibery.io/t/help-automatically-adding-list-of-related-entities-to-a-rich-text-field-document/5971/2 "2024-03-13T16:57:44Z")

</div>

> [@interr0bangr](#):
>
> `'Test Environment/Lead'`

Probably you don’t have a type named ‘Test Environment/Lead’ in your schema.

Try logging all the type names from your schema, with a Button that runs this script:

```auto
const fibery = context.getService('fibery')
const schema = await fibery.getSchema()
schema['typeObjects'].map((obj) => console.log(obj.name))

```
