Seeing undefined values when passing data between steps

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

KM_PD : Hi , about to give up on a simple nodejs script workflow. PLeaes help. i get undefined when passing values between steps. My workflow is getting data from Slack and writing to Airtable

Mohammed Zeeshan : Did you check if variables are all outputting the expected results by using a console.log statement between them?

KM_PD : Yes, console.log prints the required output.
I also added another nodejs step and printed the returned value, this.variable value in the next nodejs step. Still undefined

KM_PD :

Dylan Sather (Pipedream) : Hi , when you return inside of a function, you’re returning to the caller (myArr.forEach), but that doesn’t return the data from the step. You’ll need to return the data at the top-level of your step. I’d recommend doing something like this:

const data = []
for (const value of myArr) {
  if (value.indexOf("+") >= 0) {
    data.push(value)
  } 
}

return data

Let me know if that helps

KM_PD : Thanks! that makes sense. what is the best way to split a string, and for each word, write a record to a table then? Basically, breaking a single event into multiple events.

Dylan Sather (Pipedream) : split like you’re using now is the best way to handle that, so I think you’re on the right track

KM_PD : Ah, had to use ‘create multiple records’ for airtable - figured it out. Thanks

Dylan Sather (Pipedream) : Nice glad that worked