Set person and status when a monday.com board item is created


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 a board item is created, the person is automatically assignd who created the item and status column is set to predefined value (configurable). 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

TypeScriptOnMondayWhenAnItemIsCreated
When an item is created

README


๐Ÿ“‹ Overview

This template demonstrates how to build an automation in monday.com so when a board item is created, the person is automatically assignd who created the item and status column is set to predefined value (configurable).

๐Ÿ–Š๏ธ Setup

  • Configure the API Connection and Event Listener by creating a connector for monday.com, or use an existing one.
  • Navigate to Parameters and change the PERSON_COLUMN_LABEL, STATUS_COLUMN_LABEL and STATUS_LABEL to values that work in your board.

๐Ÿš€ Usage

Create a new item in a monday.com board, after successful event processing Person and Status columns should change accordingly for the newly created item.

API Connections


TypeScriptOnMondayWhenAnItemIsCreated

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

/**
 * This function sets the Monday.com board item creator as the assignee and sets the status to pre-defined value.
 * 
 * @param event Object that holds Issue Created event data
 * @param context Object that holds function invocation context data
 */
export default async function (event: CreateItemEvent, 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;
    }

    // Check if the pulseId is present in the event
    if (!event.event.pulseId) {
        // If not then throw an error
        throw Error('Pulse ID not present in the event');
    }

    const {PERSON_COLUMN_LABEL, STATUS_COLUMN_LABEL, STATUS_LABEL} = context.environment.vars;

    // Get all the columns, because columns are dynamic in Monday.com
    const columns = await Monday.Board.getBoards({
        fields: {
            columns: {
                fields: {
                    id: true,
                    title: true
                }
            }
        },
        args: {
            ids: [event.event.boardId]
        }
    });

    // Lookup the column for person
    const personColumn = columns.data.boards[0]?.columns.find(c => c.title === PERSON_COLUMN_LABEL)?.id;
    // Lookup the column for status
    const statusColumn = columns.data.boards[0]?.columns.find(c => c.title === STATUS_COLUMN_LABEL)?.id;

    // Check if the person column was found
    if (!personColumn) {
        // If not then throw an error
        throw Error('Person column not found');
    }

    // Check if status column was found
    if (!statusColumn) {
        // If not then throw an error
        throw Error('Status column not found');
    }

    // Finally update the item
    await Monday.Column.changeMultipleColumnValues({
        args: {
            item_id: event.event.pulseId,
            board_id: event.event.boardId,
            column_values: {
                [personColumn]: {
                    personsAndTeams: [{
                        id: event.event.userId,
                        kind: 'person'
                    }]
                },
                [statusColumn]: {
                    label: STATUS_LABEL
                }
            }
        },
        fields: {
            id: true // Even if you don't need to query anything back, having to define at least 1 field is still required for mutation
        }
    });
}
Documentation ยท Support ยท Suggestions & feature requests