The step is called google_tasks
Thank you for providing the step name. Let’s update the code to access the filteredTasks variable from the google_tasks step. Here’s the updated code for the “create_new_tasks” step: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { google_tasks: { type: "app", app: "google_tasks", }, title: { type: "string", label: "Notion Page Title", }, notionUrl: { type: "string", label: "Notion Page URL", }, dueDate: { type: "string", label: "Due Date", }, }, async run({ steps }) { const existingTasks = steps.google_tasks.filteredTasks; const title = this.title; const dueDate = this.dueDate; if (existingTasks.length > 0) { // Update the existing task's due date const taskId = existingTasks[0].id; const taskListId = existingTasks[0].taskListId; await axios(this, { method: "POST", url: `https://www.googleapis.com/tasks/v1/lists/${taskListId}/tasks/${taskId}`, headers: { Authorization: `Bearer ${this.google_tasks.$auth.oauth_access_token}`, "Content-Type": "application/json", }, data: { due: dueDate, }, }); } else { // Create a new task const url = "https://www.googleapis.com/tasks/v1/lists/@default/tasks"; const body = { title: title, due: dueDate, notes: this.notionUrl, }; await axios(this, { method: "POST", url: url, headers: { Authorization: `Bearer ${this.google_tasks.$auth.oauth_access_token}`, "Content-Type": "application/json", }, data: body, }); } }, }); This code now correctly accesses the filteredTasks variable from the google_tasks step.
I’m still getting the type error: Cannot read properties of undefined (reading ‘length’)
I apologize for the inconvenience. To further assist you, please provide the code snippet where you’re trying to access the length property. This will help me identify the issue and suggest a solution.
Cannot read properties of undefined (reading ‘length’)
DETAILS
Detailed/code mode
Google Tasks Account
Google Tasks LiveIntegrity
Notion Page Title
Look up Lencioni’s conflict exercises (For 2 hours type personal)
Notion Page URL
https://www.notion.so/Look-up-Lencioni-s-conflict-exercises-For-2-hours-type-personal-96b262325e6d438096dc19c34933de10
Due Date
2023-09-20T00:00:00+00:00
update_google_tasks_due_dates
CONFIGURE
CODE
RESULTS
query_database
CONFIGURE
update_google_tasks_completetion_status
CONFIGURE
CODE
RESULTS
google_tasks_updating_notes_duedates_completion
CONFIGURE
CODE
RESULTS
fetch_notion_tasks
CONFIGURE
CODE
RESULTS
I apologize for the confusion earlier. Based on the information provided, it’s not clear which part of the code is causing the error. To help you better, please provide the code snippet where you’re trying to access the length property. This will help me identify the issue and suggest a solution.
This is the snippet:
async run({ steps }) {
const existingTasks = steps.google_tasks.filteredTasks;
const title = this.title;
const dueDate = this.dueDate;
if (existingTasks.length > 0) {
// Update the existing task's due date
const taskId = existingTasks[0].id;
const taskListId = existingTasks[0].taskListId;
It seems like the existingTasks variable might be undefined, causing the error. To fix this issue, you can add a check to ensure existingTasks is defined before accessing its length property. Here’s the updated code snippet: async run({ steps }) { const existingTasks = steps.google_tasks.filteredTasks; const title = this.title; const dueDate = this.dueDate; if (existingTasks && existingTasks.length > 0) { // Update the existing task's due date const taskId = existingTasks[0].id; const taskListId = existingTasks[0].taskListId; // ... } // ... } This should prevent the error from occurring when accessing the length property of existingTasks.