How to Automatically Send Notion Tags (Multi-select) Values to Google Sheets Without Getting "Undefined"?

This topic was automatically generated from Slack. You can find the original thread here.

Hello. I was hoping to find some help or examples for an action to send Notion Tags (Multi-select) values to Google Sheets.

Currently, I have to manually grab each value, ( I have 100+ tags) on a Notion database field. But when I enter them in manually to parse to Google Sheets, if the tag doesn’t exist, I get “undefined” populated into the Google Sheets cell.

How can I grab the entire list of tags for this Notion database field?

My final output needs to be in the Google cell, the same as in Notion:

Child, Parent, Sibling, Grandparents, (etc…)

But not place “undefined” for each tag that is not set.

This sounds like a good case for a Data Store.

You can store all of the available tags for a Notion database field into Data Store, then you can use the presence of tags in that action you shared to determine the “missing” value of the other tags.

There aren’t any demos of the Notion Multi-select to G-sheets cell?

No sorry, we don’t have a specific tutorial on how to store Notion multi-select values and collapsing them into a single Google Sheets cell.

But with Node.js and Data Stores you can transform and enrich the data from Notion to accomplish this.

Hmm. No simple expressions for the string?

Sorry, I don’t quite understand what you’re asking. Could you rephrase?

Instead of:

{{steps.trigger.event.properties["Authorized People (new)"].multi_select[0].name}}, {{steps.trigger.event.properties["Authorized People (new)"].multi_select[1].name}}, {{steps.trigger.event.properties["Authorized People (new)"].multi_select[3].name}}, {{steps.trigger.event.properties["Authorized People (new)"].multi_select[4].name}}, {{steps.trigger.event.properties["Authorized People (new)"].multi_select[5].name}}

I couldn’t use an expression like:

{{steps.trigger.event.properties["Authorized People (new)"].multi_select[0-*].name}}

(i’m not a programmer :shrug: )

given there’s a step export steps.trigger.event.properties["Authorized People (new)"].multi_select that contains an array of objects, and each object has a name property, could you show me how to use a Node.js code step to extract all of the name properties into a single array of strings?

Certainly! You can use a Node.js code step with the map function to extract the name properties from the array of objects. Here’s an example: export default defineComponent({ async run({ steps }) { const multiSelect = steps.trigger.event.properties["Authorized People (new)"].multi_select; const names = multiSelect.map(item => item.name); return names; }, }); This code step takes the multi_select array from the steps.trigger.event.properties["Authorized People (new)"] and maps each object’s name property into a new array called names. The names array will contain all the name properties as strings.

could you also add a filter to that code step to remove null or undefined values? We want only strings to remain

Sure! You can use the filter function to remove null or undefined values from the names array. Here’s the updated code: export default defineComponent({ async run({ steps }) { const multiSelect = steps.trigger.event.properties["Authorized People (new)"].multi_select; const names = multiSelect.map(item => item.name).filter(name => name !== null && name !== undefined); return names; }, }); This code step filters out any null or undefined values from the names array, leaving only strings.

I ran it, it grabbed the 5 values from the Notion field (there are many more), however, how would I use that Node.js function to the datastore?

Well, I will go ahead and pay for Bardeen.ai, or Notion2sheets.

If Pipedream decides to add a support field for Notion Multiselect fields, it would be easier for non-coders to use, then I will try again, if that happens.

To be honest, I thought that the “Update Row” Action would go ahead and update the G-sheet entire row.

But it only updates the first cell (column)

Am I missing something?

Because I have to have an action for each cell, and its a lot of actions executing just for one row.

I thought the Update_Row action for Google Sheets would update the entire row, not just the first cell in the A-column

Okay. sorry, I see the cell/columns to pass an array with the Update Row action.