Automate linking between referenced entities

Hi, I’d like to find out if anyone might know how to automate entity linking when using references?

e.g. I have a page where we gave conversations and create insights from these conversations on another page called insights by highlighting text and linking to an insight or creating a new one.

When viewing the insight, it shows where it was referenced from but I’d like to add the original entity using relationship field columns.

I’ve looked at automations and the best I can do is link all the conversations, not just the one where it was referenced.

Perhaps there’s a script for filtering out the individual conversation before linking conversations?

Is it correctly understood that you would like to auto-link an entity to any other entity that mentions/refers to it?

conversations mention/refer to insights
insights <-> conversations (many-to-many relation) to be linked whenever a mention occurs

It is possible using a script in an automation rule, see here:

and here:

1 Like

Thanks Chris, I’ll try that.

@Chr1sG I think “How can I display References in my Board and Feed views?” seems like the closest.

My sandbox board has 3 databases - Customers, Conversations and Insights

We add new customer conversations to ‘conversations’ and have a relationship field linking to the relevant customer.

If any conversation notes are highlighted, we link those to existing/new entities on the insights DB.
The insights DB has a relation column to conversations and a lookup column for the client(s) linked to the conversation.

Currently the Insights entities only display the list of references and I’d like to automatically populate the relation fields for conversations and clients (with the lookup, this automatically adds a client when a conversation is linked).

I’d like to know how to write the script for the above if possible?

You’ll want an automation (in your Insight DB) that looks something like this:

This is the script, but you’ll need to change the SPACE NAME to be correct, at least. Maybe also the database name (Conversation in the example below) and the field name that is used for linking Conversations to an Insight (Conversations in the example below):

const fibery = context.getService('fibery');
for (const entity of args.currentEntities) {
    const entityWithRefs = await fibery.getEntityById(entity.type, entity.id, ["References"]);

    for (const ref of entityWithRefs["References"]) {
        const refdoc = await fibery.getEntityById("Collaboration~Documents/Reference", ref["Id"], ["FromEntityId"]);
        const refentity = await fibery.getEntityById("SPACE NAME/Conversation", refdoc["FromEntityId"], ["Name"]);

        if (refentity != null) {
            await fibery.addCollectionItem(entity.type, entity.id, "Conversations", refentity['Id']);
        }
    }
}
1 Like

Thanks, I got it to work. Appreciate the help.

1 Like

Hooray :tada:

I wonder: what are you trying to achieve at the end?

  • see relevant Insights when opening a Customer record?
  • calculate how many paid Customers are connected to a particular Insight?

Maybe, going one step further: what questions you’d like to answer, what decisions you’d like to make?

We are working on a similar set of use cases right now, and it’d be great to incorporate your scenarios as well.