I am using Zapier to create a Monday.com task every time a new lead is created in Copper (my CRM). The problem is that Zapier only allows the information to stored in the task name on Monday.com. I have created a webhook that is supposed to parse the needed data out of the Monday.com task title and update the column values as needed. However, my code is currently not doing that. I am receiving no errors when I create a task yet the columns are not populating properly. I am not sure what is the issue.
Here is the code:
const express = require('express')
const path = require('path')
const bodyParser = require('body-parser')
const PORT = process.env.PORT || 5000
const updateMultipleColumnValues = require("./updateMultipleColumnValue").updateMultipleColumnValue;
const app = express();
app.use( bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.post('/', (req, res) => {
console.log(req.body)
const { boardId, pulseId } = req.body.event
let parsedRecord = extractData(req.body.event.pulseName)
console.log(parsedRecord);
let newData = {
"text0": parsedRecord.DURATION
};
let stringData = JSON.stringify(newData);
console.log(boardId);
console.log(pulseId);
console.log(stringData);
updateMultipleColumnValues(boardId, pulseId, stringData);
res.json(parsedRecord);
});
app.listen(PORT, () => console.log(`Listening on ${ PORT }`));
// console.log(extractData(targetStr, fields));
function extractData(str) {
let fields = ['DATE', 'TIME', 'DURATION', 'TYPE'];
return str.split(/\s*\|\s*/).reduce((res, entry) => {
let dat = entry.split(/\s*:\s*/);
return fields.indexOf(dat[0]) > -1 ? Object.assign(res, { [dat[0]]: dat[1] }) : res;
}, {});
}
Here is the updateMultipleColumnValue file:
const executeMondayQuery = require("./executeMondayQuery").executeMondayQuery;
const updateMultipleColumnValue = async (boardId, itemId, newData) => {
const updateColumnValueBody = {
query: `mutation {
change_multiple_column_values(
board_id: ${boardId},
item_id: ${itemId},
column_values: ${newData}
) { id }
}`
};
await executeMondayQuery(updateColumnValueBody);
};
exports.updateMultipleColumnValue = updateMultipleColumnValue;
Monday.com use graphQL