{ "name": "Create Latest Sheet Event in Google Calendar", "tags": [], "nodes": [ { "id": "create-latest-sheet-event-in-google-calendar-0", "name": "Event Date Formatter", "type": "n8n-nodes-base.code", "position": [ 320, 100 ], "parameters": { "jsCode": "// Get the last item from the input data\nconst lastEvent = items[items.length - 1].json;\n\n// Extract relevant fields\nconst eventName = lastEvent[\"Event Name\"];\nconst eventDescription = lastEvent[\"Event Description\"];\nconst currentYear = new Date().getFullYear(); \n// Get the current year\nconst location = lastEvent[\"Location\"];\n\n// Ensure the date includes the year\nconst formatDateWithYear = (dateStr) => {\n return dateStr.includes(currentYear) ? dateStr : `${dateStr} ${currentYear}`;\n};\n\n// Format the start date\nconst startDateString = formatDateWithYear(lastEvent[\"Event Start Date\"]); // Example: \"11 March 2024\"\n\n// Convert to JavaScript Date object\nconst startDate = new Date(startDateString + ' UTC');\n\n// Convert to ISO format (YYYY-MM-DD)\nconst formattedStartDate = startDate.toISOString().split(\"T\")[0]; // Extract only the date\n\n// Return the last event's formatted data\nreturn [{\n json: {\n eventName,\n eventDescription,\n startDate: formattedStartDate,\n location: location,\n }\n}];\n" }, "typeVersion": 2 }, { "id": "create-latest-sheet-event-in-google-calendar-1", "name": "New Event Entry Listener", "type": "n8n-nodes-base.googleSheetsTrigger", "position": [ -120, 100 ], "parameters": { "event": "rowAdded", "options": { "valueRender": "FORMULA" }, "pollTimes": { "item": [ { "mode": "everyMinute" }, {} ] }, "sheetName": { "__rl": true, "mode": "name", "value": "Sheet1" }, "documentId": { "__rl": true, "mode": "id", "value": "YOUR_SPREADSHEET_ID" } }, "typeVersion": 1 }, { "id": "create-latest-sheet-event-in-google-calendar-2", "name": "Google Calendar Event Creator", "type": "n8n-nodes-base.googleCalendar", "position": [ 700, 100 ], "parameters": { "end": "={{ new Date(Date.parse($json.startDate) + 86400000).toISOString().slice(0,10) }}", "start": "={{ $json.startDate }}", "calendar": { "__rl": true, "mode": "id", "value": "primary" }, "additionalFields": { "color": "3", "allday": "yes", "summary": "={{ $json.eventName }}", "location": "={{ $json.location }}", "showMeAs": "transparent", "description": "={{ $json.eventDescription }}", "guestsCanInviteOthers": true } }, "typeVersion": 1.3 } ], "active": false, "pinData": {}, "settings": { "executionOrder": "v1", "timezone": "UTC" }, "connections": { "Event Date Formatter": { "main": [ [ { "node": "Google Calendar Event Creator", "type": "main", "index": 0 } ] ] }, "New Event Entry Listener": { "main": [ [ { "node": "Event Date Formatter", "type": "main", "index": 0 } ] ] } } }