I am using Zapier to create a new Monday pulse everytime a specific action happens in my CRM. The problem is that zapier only allows access to the pulse title so all my data is dumped in the title. I have created a node.js script that parses out the desired information and then mutates multiple column values you move that data into the appropriate column. I can’t for the life of me get it to work and the documentation is not helping. Any help would be appreciated.
Here is my index.js file:
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 }`));
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;
}, {});
}
and here is my update column script
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;