Reporting based on references

I was wondering if there is any way of aggregating and reporting based on References/Back Links.

E.g. I have a set of initiatives which are discussed at various meetings. However, most of my meetings are not about initiatives, so in order to keep the number of explicit relations (and resulting mess in the front end) to a minimum, I have just been referring to these initiatives in my meeting entities with an inline reference. This way I can go back to the initiative entity and sort of get a list of meetings where it was referenced. However, at the moment, there doesn’t seem to be a way of categorizing back links (e.g. group them by the originating entity type) or generate any reports, like how many meeting we had where this initiative was discussed and how many hours does that represent.

I was wondering if this is somehow already possible.

I was able to output the information through a script (currently just outputting into console but will write back to a markdown table) so that I can do the analysis in another tool. However, if there was a way of making better use of References in Fibery, that would be great :slight_smile:

One of the things I noticed is that when there are multiple references in the same entity, then multiple instances come back. It would be great to be able to group my referring entity and the number of references.

// Script parameters
const PARENT_TYPE = 'Work Spaces/Initiative';
const REF_ENTITY_TYPES = ['Project Management/Project Meeting'];
const REF_ENTITY_FIELDS = ['Name', 'Date', 'Duration'];

// Fibery API is used to retrieve and update entities
const fibery = context.getService('fibery');

// Iterate through the entities
for (const entity of args.currentEntities) {
    const entityWithRefs = await fibery.getEntityById(entity.type,, ['References']);

    // Iterate through the references
    for (const ref of entityWithRefs['References']) {
        const refDoc = await fibery.getEntityById('Collaboration~Documents/Reference', ref['Id'], ['FromEntityId', 'FromEntityType']);
        const refType = refDoc['FromEntityType'].name;

        if (REF_ENTITY_TYPES.includes(refType)) {
            // Referring entity has a relation to the PARENT_TYPE
            const refEntity = await fibery.getEntityById(refType, refDoc['FromEntityId'], REF_ENTITY_FIELDS);
            if (refEntity != null) {
                var refEntityDate = new Date(refEntity['Date'].Start);
                console.debug(refEntity.Id + "," + refEntity['Name'] + "," + refEntityDate.toLocaleDateString("en-US") + "," + refEntity['Duration'] + ",");

This sort of thing is actually possible using a formula, but

is not really possible without scripting.

It boils down to the fact that refs are effectively polymorphic.
You can filter by referring type and count them, but you can’t extract info (field values) from the referring entities.

See here