How to Modify Code to Filter the Correct Google Task List in a Notion Database Update Workflow?

I apologize for the oversight. It seems I missed adding the import statement for axios. Here’s the corrected code with the import statement: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { taskIDPropertyName: { type: “string”, label: “Task ID Property Name”, }, dueDatePropertyName: { type: “string”, label: “Due Date Property Name”, }, titlePropertyName: { type: “string”, label: “Title Property Name”, }, notionURL: { type: “string”, label: “Notion URL”, }, }, async run({ steps }) { const notionPage = await axios(this, { method: “GET”, url: this.notionURL, }); const taskId = notionPage.properties[this.taskIDPropertyName].rich_text[0].text.content; const dueDate = notionPage.properties[this.dueDatePropertyName].date.start; const taskTitle = notionPage.properties[this.titlePropertyName].title[0].text.content; return { taskId, dueDate, taskTitle }; }, });

I’m using this code:
import { axios } from@pipedream/platform”;

export default defineComponent({
props: {
taskIDPropertyName: {
type: “string”,
label: “Task ID Property Name”,
},
dueDatePropertyName: {
type: “string”,
label: “Due Date Property Name”,
},
titlePropertyName: {
type: “string”,
label: “Title Property Name”,
},
notionURL: {
type: “string”,
label: “Notion URL”,
},
},
async run({ steps }) {
const notionPage = await axios(this, {
method: “GET”,
url: this.notionURL,
});

**const** taskId = notionPage.properties[**this**.taskIDPropertyName].rich_text[0].text.content;
**const** dueDate = notionPage.properties[**this**.dueDatePropertyName].date.start;
**const** taskTitle = notionPage.properties[**this**.titlePropertyName].title[0].text.content;

**return** { taskId, dueDate, taskTitle };

},
});
But I’m getting this error: TypeError
Cannot read properties of undefined (reading ‘3f2c7420-caff-4a31-983c-d5b027d2c06f’)

I apologize for the confusion. It seems there might be an issue with the data returned from the Notion API. To better understand the issue, let’s add some error handling and logging to the code: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { taskIDPropertyName: { type: “string”, label: “Task ID Property Name”, }, dueDatePropertyName: { type: “string”, label: “Due Date Property Name”, }, titlePropertyName: { type: “string”, label: “Title Property Name”, }, notionURL: { type: “string”, label: “Notion URL”, }, }, async run({ steps }) { try { const notionPage = await axios(this, { method: “GET”, url: this.notionURL, }); console.log(“Notion Page Data:”, notionPage); const taskId = notionPage.properties[this.taskIDPropertyName].rich_text[0].text.content; const dueDate = notionPage.properties[this.dueDatePropertyName].date.start; const taskTitle = notionPage.properties[this.titlePropertyName].title[0].text.content; return { taskId, dueDate, taskTitle }; } catch (error) { console.error(“Error fetching Notion page data:”, error); throw error; } }, });

This is one of the errors: Error fetching Notion page data: at Object.run (file:///tmp/pdg/dist/code/e25cf68e939a0e4fcfde1f0619a1b47f4ac6835294a0c14f85b233646285ec8a/component.mjs:31:43)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at null.executeComponent (/var/task/launch_worker.js:229:22)
at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)

I apologize for the confusion earlier. It seems the error is not providing enough information to identify the root cause. Let’s add more detailed logging to the code to better understand the issue: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { taskIDPropertyName: { type: “string”, label: “Task ID Property Name”, }, dueDatePropertyName: { type: “string”, label: “Due Date Property Name”, }, titlePropertyName: { type: “string”, label: “Title Property Name”, }, notionURL: { type: “string”, label: “Notion URL”, }, }, async run({ steps }) { try { const notionPage = await axios(this, { method: “GET”, url: this.notionURL, }); console.log(“Notion Page Data:”, notionPage); const taskId = notionPage.properties[this.taskIDPropertyName].rich_text[0].text.content; const dueDate = notionPage.properties[this.dueDatePropertyName].date.start; const taskTitle = notionPage.properties[this.titlePropertyName].title[0].text.content; return { taskId, dueDate, taskTitle }; } catch (error) { console.error(“Error fetching Notion page data:”, error); console.error(“Error details:”, error.response.data); throw error; } }, });

The Task ID is in this path {{steps.trigger.event.id}}. Could that be causing the problem?

Yes, it’s possible that the issue is related to accessing the Task ID from the trigger step. To fix this, you can update the code to use the Task ID from the trigger step like this: export default defineComponent({ props: { dueDatePropertyName: { type: "string", label: "Due Date Property Name", }, titlePropertyName: { type: "string", label: "Title Property Name", }, notionURL: { type: "string", label: "Notion URL", }, }, async run({ steps }) { try { const notionPage = await axios(this, { method: "GET", url: this.notionURL, }); console.log("Notion Page Data:", notionPage); const taskId = steps.trigger.event.id; const dueDate = notionPage.properties[this.dueDatePropertyName].date.start; const taskTitle = notionPage.properties[this.titlePropertyName].title[0].text.content; return { taskId, dueDate, taskTitle }; } catch (error) { console.error("Error fetching Notion page data:", error); console.error("Error details:", error.response.data); throw error; } }, }); Now, the code uses steps.trigger.event.id to get the Task ID. Please try running the updated code and let me know if the issue persists.

I’m now getting this error:
TypeError
Cannot read properties of undefined (reading ‘data’)
DETAILS

    at Object.run (file:///tmp/__pdg__/dist/code/4ba1c57743a2d571080cd35307967bdea81dc126e05e0c73ee44684830351f57/component.mjs:34:54)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at null.executeComponent (/var/task/launch_worker.js:229:22)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)

Detailed/code mode
Due Date Property Name
{ “formula”: { “string”: “2023-09-21T00:00:00+00:00”, “type”: “string” }, “id”: “PyKz”, “type”: “formula” }
Title Property Name
testing due dates moving
Notion URL

I see the issue now. The error is caused by trying to access the data property of the response, but with the @pipedream/platform axios, the response data is returned directly, not within a data property. To fix this, update the code as follows: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { dueDatePropertyName: { type: "string", label: "Due Date Property Name", }, titlePropertyName: { type: "string", label: "Title Property Name", }, notionURL: { type: "string", label: "Notion URL", }, }, async run({ steps }) { try { const notionPage = await axios(this, { method: "GET", url: this.notionURL, }); console.log("Notion Page Data:", notionPage); const taskId = steps.trigger.event.id; const dueDate = notionPage.properties[this.dueDatePropertyName].formula.string; const taskTitle = notionPage.properties[this.titlePropertyName].title[0].text.content; return { taskId, dueDate, taskTitle }; } catch (error) { console.error("Error fetching Notion page data:", error); console.error("Error details:", error.response.data); throw error; } }, }); I’ve updated the line that accesses the dueDate property to use notionPage.properties[this.dueDatePropertyName].formula.string. Please try running the updated code and let me know if the issue persists.

With this code:

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    dueDatePropertyName: {
      type: "string",
      label: "Due Date Property Name",
    },
    titlePropertyName: {
      type: "string",
      label: "Title Property Name",
    },
    notionURL: {
      type: "string",
      label: "Notion URL",
    },
  },
  async run({ steps }) {
    try {
      const notionPage = await axios(this, {
        method: "GET",
        url: this.notionURL,
      });

      console.log("Notion Page Data:", notionPage);

      const taskId = steps.trigger.event.id;
      const dueDate = notionPage.properties[this.dueDatePropertyName].formula.string;
      const taskTitle = notionPage.properties[this.titlePropertyName].title[0].text.content;

      return { taskId, dueDate, taskTitle };
    } catch (error) {
      console.error("Error fetching Notion page data:", error);
      console.error("Error details:", error.response.data);
      throw error;
    }
  },
});

With this code: With this code:

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    dueDatePropertyName: {
      type: "string",
      label: "Due Date Property Name",
    },
    titlePropertyName: {
      type: "string",
      label: "Title Property Name",
    },
    notionURL: {
      type: "string",
      label: "Notion URL",
    },
  },
  async run({ steps }) {
    try {
      const notionPage = await axios(this, {
        method: "GET",
        url: this.notionURL,
      });

      console.log("Notion Page Data:", notionPage);

      const taskId = steps.trigger.event.id;
      const dueDate = notionPage.properties[this.dueDatePropertyName].formula.string;
      const taskTitle = notionPage.properties[this.titlePropertyName].title[0].text.content;

      return { taskId, dueDate, taskTitle };
    } catch (error) {
      console.error("Error fetching Notion page data:", error);
      console.error("Error details:", error.response.data);
      throw error;
    }
  },
});

I’m getting this error: TypeError
Cannot read properties of undefined (reading ‘data’)
DETAILS

    at Object.run (file:///tmp/__pdg__/dist/code/e783e92bab6331359e0474dee67aa56e216910e0ebd3c1f1ba9ebd4aee5f7a6e/component.mjs:34:54)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at null.executeComponent (/var/task/launch_worker.js:229:22)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28

Detailed/code mode
Due Date Property Name
{ “formula”: { “string”: “2023-09-21T00:00:00+00:00”, “type”: “string” }, “id”: “PyKz”, “type”: “formula” }
Title Property Name
testing due dates moving
Notion URL

It looks like you’re trying to access the properties of the Notion page using notionPage.properties, but the actual data is in notionPage.data.properties. To fix the error, update your code as follows: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { dueDatePropertyName: { type: “string”, label: “Due Date Property Name”, }, titlePropertyName: { type: “string”, label: “Title Property Name”, }, notionURL: { type: “string”, label: “Notion URL”, }, }, async run({ steps }) { try { const notionPage = await axios(this, { method: “GET”, url: this.notionURL, }); console.log(“Notion Page Data:”, notionPage); const taskId = steps.trigger.event.id; const dueDate = notionPage.data.properties[this.dueDatePropertyName].formula.string; const taskTitle = notionPage.data.properties[this.titlePropertyName].title[0].text.content; return { taskId, dueDate, taskTitle }; } catch (error) { console.error(“Error fetching Notion page data:”, error); console.error(“Error details:”, error.response.data); throw error; } }, });

Getting this error: TypeError
Cannot read properties of undefined (reading ‘data’)

at Object.run (file:///tmp/__pdg__/dist/code/1b000d5ec4e093cf8482b2cf162b050ec6e99adcf3a7db5ef77cfa7b7c9f3552/component.mjs:34:54)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at null.executeComponent (/var/task/launch_worker.js:229:22)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)

I apologize for the confusion earlier. It seems I made a mistake in my previous response. Let’s try to debug the issue together. Can you please provide the response you get when you log the notionPage variable using console.log("Notion Page Data:", notionPage);? This will help me understand the structure of the response and suggest the correct way to access the properties.

Here’s the log (or as much as I can paste): Notion Page Data: !doctype html<meta name=“viewport” content=“width=device-width,height=device-height,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover”>Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.<meta name=“description” content=“A new tool that blends your everyday work apps into one. It’s the all-in-one workspace for you and your team”><meta name=“twitter:title” content=“Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.“><meta name=“twitter:description” content=“A new tool that blends your everyday work apps into one. It’s the all-in-one workspace for you and your team”><meta property=“og:title” content=“Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.“><meta property=“og:description” content=“A new tool that blends your everyday work apps into one. It’s the all-in-one workspace for you and your team”><link rel=“shortcut icon” type=“image/x-icon” href=“/images/favicon.ico”><meta name=“apple-itunes-app” content=“app-id=1232780281”><meta name=“format-detection” content=“telephone=no”>body{background:#fff}body.dark{background:#191919}@keyframes startup-shimmer-animation{0%{transform:translateX(-100%) translateZ(0)}100%{transform:translateX(100%) translateZ(0)}}@keyframes startup-shimmer-fade-in{0%{opacity:0}100%{opacity:1}}@keyframes startup-spinner-rotate{0%{transform:rotate(0) translateZ(0)}100%{transform:rotate(360deg) translateZ(0)}}#initial-loading-spinner{position:fixed;height:100vh;width:100vw;z-index:-1;display:none;align-items:center;justify-content:center;opacity:.5}#initial-loading-spinner svg{height:24px;width:24px;animation:startup-spinner-rotate 1s linear infinite;transform-origin:center center;pointer-events:none}#skeleton{background:#fff;position:fixed;height:100vh;width:100vw;z-index:-1;display:none;overflow:hidden}#initial-loading-spinner.show,#skeleton.show{display:flex}body.dark #skeleton{background:#191919}.notion-front-page #skeleton,.notion-mobile #skeleton{display:none}#skeleton-sidebar{background-color:#fbfbfa;box-shadow:inset -1px 0 0 0 rgba(0,0,0,.025);display:flex;width:240px;flex-direction:column;padding:12px 14px;overflow:hidden}body.dark #skeleton-sidebar{background-color:#202020;box-shadow:inset -1px 0 0 0 rgba(255,255,255,.05)}#skeleton.isElectron #skeleton-sidebar{padding-top:46px}#skeleton .row{display:flex;margin-bottom:8px;align-items:center}#skeleton .row.fadein{animation:1s ease-in 0s 1 normal both running startup-shimmer-fade-in}#skeleton .chevron{width:12px;height:12px;display:block;margin-right:4px;fill:rgba(227,226,224,.5)}body.dark #skeleton .chevron{fill:#2f2f2f}.startup-shimmer{background:rgba(227,226,224,.5);overflow:hidden;position:relative}body.dark .startup-shimmer{background:#2f2f2f}.startup-shimmer::before{content:“”;position:absolute;height:100%;width:100%;z-index:1;animation:1s linear infinite startup-shimmer-animation;background:linear-gradient(90deg,transparent 0,rgba(255,255,255,.4) 50%,transparent 100%)}body.dark .startup-shimmer::before{background:linear-gradient(90deg,transparent 0,rgba(86,86,86,.4) 50%,transparent 100%)}#skeleton .icon{width:20px;height:20px;border-radius:4px}#skeleton .text{height:10px;border-radius:10px}#skeleton .draggable{-webkit-app-region:drag;position:absolute;top:0;left:0;width:100%;height:36px;display:none}#skeleton.isElectron .draggable{display:block}

<svg xmlns=“http://www.w3.org/2000/svg” viewBox=“0 0 24 24"><stop stop-color=“rgba(164, 164, 164, 1)” offset=“0%“/><stop stop-color=“rgba(164, 164, 164, 0)” stop-opacity=“0" offset=“100%“/><g stroke=“none” stroke-width=“1" fill=“none”><g transform=“translate(-236.000000, -286.000000)“><g transform=“translate(238.000000, 286.000000)“><circle id=“Oval-2” stroke=“url(#linearGradient-1)” stroke-width=“4” cx=“10" cy=“12” r=“10"/><path d=“M10,2 C4.4771525,2 0,6.4771525 0,12” id=“Oval-2" stroke=“rgba(164, 164, 164, 1)” stroke-width=“4"/><rect id=“Rectangle-1” fill=“rgba(164, 164, 164, 1)” x=“8” y=“0" width=“4” height=“4" rx=“8”/>
<div class=“startup-shimmer icon” style=“width:22px;height:22px;padding:1px”>
<div class=“startup-shimmer text” style=“width:177px;margin-left:8px”>
<div class=“startup-shimmer text” style=“width:78px”>
<div class=“startup-shimmer text” style=“width:78px”>
<div class=“startup-shimmer text” style=“width:135px”>
<div class=“startup-shimmer text” style=“width:56px”>
<svg viewBox=“0 0 30 30” class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8”><div class=“startup-shimmer icon”>
<div class=“startup-shimmer text” style=“width:100px;margin-left:6px”>
<svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”>
<div class=“startup-shimmer text” style=“width:140px;margin-left:6px”>
<svg viewBox=“0 0 30 30” class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8”><div class=“startup-shimmer icon”>
<div class=“startup-shimmer text” style=“width:140px;margin-left:6px”>
<svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”>
<div class=“startup-shimmer text” style=“width:100px;margin-left:6px”><div class=“row fadein” style=“animation-delay:1s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text” style=“width:100px;margin-left:6px”><div class=“row fadein” style=“animation-delay:1s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text” style=“width:100px;margin-left:6px”><div class=“row fadein” style=“animation-delay:1s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text” style=“width:100px;margin-left:6px”><div class=“row fadein” style=“animation-delay:1s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text” style=“width:140px;margin-left:6px”><div class=“row fadein” style=“animation-delay:2s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text” style=“width:140px;margin-left:6px”><div class=“row fadein” style=“animation-delay:2s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text” style=“width:140px;margin-left:6px”><div class=“row fadein” style=“animation-delay:2s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text” style=“width:120px;margin-left:6px”><div class=“row fadein” style=“animation-delay:2s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text” style=“width:120px;margin-left:6px”><div class=“row fadein” style=“animation-delay:3s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text” style=“width:120px;margin-left:6px”><div class=“row fadein” style=“animation-delay:3s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text” style=“width:120px;margin-left:6px”><div class=“row fadein” style=“animation-delay:3s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text” style=“width:140px;margin-left:6px”><div class=“row fadein” style=“animation-delay:3s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text” style=“width:80px;margin-left:6px”><div class=“row fadein” style=“animation-delay:4s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text” style=“width:100px;margin-left:6px”><div class=“row fadein” style=“animation-delay:4s”><svg viewBox=“0 0 30 30" class=“chevron”><polygon points=“17.4,15 7,25.2 9.8,28 23,15 9.8,2 7,4.8"><div class=“startup-shimmer icon”><div class=“startup-shimmer text”

I’m trying to create a worflow that that updates the due date of a Google Task when the due date is changed in Notion. I’m trying to Add a custom code step to extract the Notion Private URL, due date, and title from the updated Notion page:

To create a workflow that updates the due date of a Google Task when the due date is changed in Notion, you can start by using the “Updated Page in Database” trigger for Notion. Here’s how to set up the trigger: 1. Search for the Notion app from the trigger menu 2. Select the “Updated Page in Database” trigger 3. Connect your Notion account 4. Select a Database ID or pass a string from a previous step 5. Follow the instructions on the trigger configuration screen. You may need to generate a test event from Notion to get real data to test your workflow. Once you have the trigger set up, you can add a custom code step to extract the Notion Private URL, due date, and title from the updated Notion page. Here’s an example of how you can extract this information: export default defineComponent({ async run({ steps }) { const updatedPage = steps.trigger.event; const title = updatedPage.properties.Title.title[0].plain_text; const dueDate = updatedPage.properties.Due_Date.date.start; const privateUrl = updatedPage.url; return { title, dueDate, privateUrl }; }, }); Make sure to replace Title and Due_Date with the actual property names in your Notion database. After extracting the required information, you can use a Google Tasks action or custom code to update the due date of the corresponding Google Task.

Would it work in the code to make the information props in the configuration part of the step?

Yes, you can use props in the configuration part of the custom code step to allow users to input the required information. Here’s an example of how you can modify the code to use props for the Notion Private URL, due date, and title: export default defineComponent({ props: { notionPrivateUrl: { type: "string", label: "Notion Private URL", }, dueDate: { type: "string", label: "Due Date", }, title: { type: "string", label: "Title", }, }, async run({ steps }) { const privateUrl = this.notionPrivateUrl; const dueDate = this.dueDate; const title = this.title; return { title, dueDate, privateUrl }; }, }); This code defines three props: notionPrivateUrl, dueDate, and title. Users can input the required information for these props in the Pipedream UI when they add the custom code step to their workflow.

What action should I use to update the due dates of the matching google tasks?