Tree Hierarchy in Tabidoo

Hi, Jason again…
I have created the table Tasks. For every Task it is possible to set superior Task (link to table Task:Task).
I can now see Tasks in hierarchical view (GRID).
But I don’t know how to limit number of levels in hierarchy. In my case I need to limit to 3 levels.
thanks for the tip

Hello Jason,

thank you for an interesting question. It is good to know that you are using the hierarchy view.
There is a way how to control the level of nesting, it can be set by JavaScript:

const ticketTableId = ‘tasks’;

doo.model.isValid = true;
await parentTicketConstraint();

async function parentTicketConstraint() {
    const parentTicketCountPromise = calculateParentTicketsCount(doo.model.linkedField?.value?.id);
    const childTicketCountPromise = calculateChildTicketsCount(;

    const parentTicketCount = await parentTicketCountPromise;
    const childTicketCount = await childTicketCountPromise;

    if (parentTicketCount + childTicketCount >= 2) {
        doo.model.isValid = false;
        doo.toast.error('Tasks cannot have a nesting level greater than 2.', 'Error');

// returns count of Parent tickets of the current ticket
async function calculateParentTicketsCount(parentTicketId?: string): Promise<number> {
    if (!parentTicketId)
        return 0;

    const parentTicket = await doo.table.getRecord(ticketTableId, parentTicketId);
    let parentsCount = await calculateParentTicketsCount(;

    return parentsCount + 1;

// returns count of child tickets of the current ticket
async function calculateChildTicketsCount(ticketId?: string): Promise<number> {
    if (!ticketId)
        return 0;

    const childTickets = await doo.table.getLinkedRecordsV2(ticketTableId, ticketId, 'linkedField');

    if ( === 0)
        return 0;

    let promises = [];

    for (let childTicket of {
        const promise = calculateChildTicketsCount(;

    let maxDepth = 0;

    for (let promise of promises) {
        let currentDepth = await promise;

        if (maxDepth < currentDepth)
            maxDepth = currentDepth;

    return maxDepth + 1;

We would most likely use it in the section Before save as it is bound to the validity of the model.
I hope this helps you to manage your table even better.


I will give it a try. Thanks Anna for fast answer.