How to retrieve a linked entity from Rich Text via its markdown?

In Rich Text a linked entity looks something like this when exported to Markdown:

[[#^7517bc49-058a-4533-850e-67b7894c6f2e/bec1ecb0-172d-11ec-a8bb-d12073fec656]]

How can I translate this into a Type and Id that I can use with getEntityById()?

If I interpret the string as [[#^type/id]], I get:
Failed to execute Action "Script": type 7517bc49-058a-4533-850e-67b7894c6f2e was not found in schema

The name of the type can be found as follows:

const fibery = context.getService('fibery');
const schema = await fibery.getSchema();
const typeName = schema.typeObjects.filter((obj) => obj.id == '7517bc49-058a-4533-850e-67b7894c6f2e')[0].name;
console.log(typeName);

You can then use the type name in all the normal script functions :slight_smile:

1 Like

The entity info (and type) will vary, so I suppose I need to look up the type for each one.