I’m trying to use the example given in Fibery’s markdown documentation here 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:
{!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:
{!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:
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?