Please Help Creating Custom Airtable Step

Hi Team.

Quick background in case I have the totally wrong approach here. I’m trying to migrate from Integromat, but without an iterator flow control, I’ve worked out that I need to make a custom Airtable step. My JS is rusty but passable.

I tried making a custom iterator step for flow control but that didn’t work. I was able to console.log all of the array objects, but when I put $.export inside the loop, only the final value seemed to be passed to the next step. So… I found that I needed to modify an air table step to put it in a loop. And since I have to make a custom step anyway, I thought I’d just combine the two required functions into one.

I want to input an array of VideoID’s (not Airtable ID’s, but they are unique). For each value, search a table to see if contains a row with that VideoID. Pass the result into the create / update (upsert) step to either update that row, or add a new row if now row was found. I have done this many times with Integromat. I tested the configuration without an iterator in PD and it worked fine for the first array object.

I think the correct path is to publish a custom component using CLI. So I set that all up and published the tutorial component.

Then I tried to copy the Airtable list-records code from github into my own JS file, but I’m already stuck unable to publish this. I get “npm install failed” in CLI. I adjusted the imports to look like:

import commonList from “@pipedream/components/airtable/actions/common-list.mjs”

Unsure if just my syntax is wrong, or I’m on the totally wrong path.

Any guidance would be much appreciated

Hi @Ty,

I understand you want to create a custom component that takes an array of VideoIDs, searches an Airtable table for each VideoID, and then either updates the existing row or creates a new one if the row is not found. I’ll guide you through the process of creating a custom component for this.

First, you don’t need to import the commonList from the Airtable component. Instead, you can use the Airtable API directly within your custom component. Here’s a basic outline of the component you can use as a starting point:

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

export default defineComponent({
  props: {
    airtable: {
      type: "app",
      app: "airtable",
    },
    baseId: {
      type: "string",
      label: "Base ID",
    },
    tableId: {
      type: "string",
      label: "Table ID",
    },
    videoIds: {
      type: "string[]",
      label: "Video IDs",
    },
  },
  async run({ $ }) {
    for (const videoId of this.videoIds) {
      // 1. Search the table for the VideoID
      // 2. If found, update the row
      // 3. If not found, create a new row
    }
  },
});

In this component, you’ll need to replace the comments with the actual code to search, update, and create rows in Airtable using the Airtable API. You can use the axios function from the @pipedream/platform package to make API requests.

Remember to check the Airtable API documentation for details on how to make requests for searching, updating, and creating records.

If you need further assistance or have any questions, please let me know!
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! Learn how to build your own.

Hi @Ty,

Can you try:
import commonList from "@pipedream/airtable/actions/common-list.mjs"

Hi, that worked! Thank you, although unsure how exactly you got that path…

In the meantime I got the basics working hand-coding everything. Able to push an array into my step and have it search and update each Video. I’ll try now to pull some of the pre-configured component code in to make my function more re-usable.

Thanks again

1 Like