Move monday.com board item to a group based on status update


Get Started

Not the template you're looking for? Browse more.

About the template


This template demonstrates how to build an automation in monday.com, so when an item's status is updated, they will be moved to a group with the matching status name. Get started to learn more.

About ScriptRunner Connect


What is ScriptRunner Connect?

ScriptRunner Connect is an AI assisted code-first (JavaScript/TypeScript) integration platform (iPaaS) for building complex integrations and automations.

Can I try it out for free?

Yes. ScriptRunner Connect comes with a forever free tier.

Can I customize the integration logic?

Absolutely. The main value proposition of ScriptRunner Connect is that you'll get full access to the code that is powering the integration, which means you can make any changes to the the integration logic yourself.

Can I change the integration to communicate with additional apps?

Yes. Since ScriptRunner Connect specializes in enabling complex integrations, you can easily change the integration logic to connect to as many additional apps as you need, no limitations.

What if I don't feel comfortable making changes to the code?

First you can try out our AI assistant which can help you understand what the code does, and also help you make changes to the code. Alternatively you can hire our professionals to make the changes you need or build new integrations from scratch.

Do I have to host it myself?

No. ScriptRunner Connect is a fully managed SaaS (Software-as-a-Service) product.

What about security?

ScriptRunner Connect is ISO 27001 and SOC 2 certified. Learn more about our security.

Template Content


README

Scripts

TypeScriptOnMondayWhenAStatusChanges
When a status changes

README


๐Ÿ“‹ Overview

This template demonstrates how to build an automation in monday.com, so when an item's status is updated, they will be moved to a group with the matching status name.

๐Ÿ–Š๏ธ Setup

  • Configure the API Connection and Event Listener by creating a connector for monday.com, or use an existing one.

๐Ÿš€ Usage

Update the status of an existing item or create an item with a status, The item should move to the group named with that status value if present.

API Connections


TypeScriptOnMondayWhenAStatusChanges

import { UpdateStatusEvent } from '@sr-connect/monday/events';
import Monday from "./api/monday";

/**
 * Entry point to When a status changes event
 *
 * @param event Object that holds When a status changes event data
 * @param context Object that holds function invocation context data
 */
export default async function (event: UpdateStatusEvent, context: Context): Promise<void> {
    if (context.triggerType === 'MANUAL') {
        console.error('This script is designed to be triggered externally or manually from the Event Listener. Please consider using Event Listener Test Event Payload if you need to trigger this script manually.');
        return;
    }

    // Extract necessary parameters from the event
    const { boardId, pulseId, value } = event.event;

    // Check if the necessary parameters are present in the event
    if (!boardId) {
        throw Error("Board ID not present in the event");
    }
    if (!pulseId) {
        throw Error("Pulse ID not present in the event");
    }
    if (!value) {
        throw Error("Value not present in the event");
    }

    // Get all the groups from a board in monday.com
    const boards = await Monday.Board.getBoards({
        args: {
            ids: [boardId],
        },
        fields: {
            groups: {
                fields: {
                    id: true,
                    title: true,
                },
            },
        },
    });

    // Find the target group to move the item to which matches the name of the new status
    const groupId = boards.data.boards[0].groups.find(g => g.title == value.label.text)?.id;

    // If no matching group exists, end script
    if (!groupId) {
        return
    }

    // Move the item to the target group
    await Monday.Item.moveItemToGroup({
        args: {
            item_id: pulseId,
            group_id: groupId,
        },
        fields: {
            id: true,
        },
    });
}
Documentation ยท Support ยท Suggestions & feature requests