Append to Array Variable
I'm retrieving data from Supabase using the Get Row node. I want to loop through the results and create a string with the relevant fields (something like: "<<firstname>> <<lastname>> will expire in <<days_until_expired>> days". I can do this when using the Log Message to Console without a problem. I want to store these strings in another variable (probably array) but I don't know how to append to an array variable. I keep getting "undefined" or "Cannot read properties of undefined (reading 'push'). How does one append to an array variable in Buildship? I can't find any documentation on it and the AI keeps returning results that don't work. This should be super easy, but maybe there's a different/better way to do this in Buildship. All I want to do is create the resultant list of formatted strings and either send an app notification or send an email with the results. Thanks in advance!
2 Replies
AI Support Bot Information
<@739544665543409737> you can react on the relevant answer (message) with a ✅ in this thread when you think it has been solved, by the bot or by a human!
Anyone can react on this message with a ❌ if the GPT bot is unhelpful or hallucinating answers.
Please note: Team members will review and answer the questions on best efforts basis.
AI Response
To append to an array variable in BuildShip, you can follow these general steps:
1. Initialize the Array Variable: Ensure that the array variable is initialized before you try to append to it. You can initialize it at the start of your loop or prior to entering the loop using a custom node or in the logic node.
2. Append to the Array: Inside your loop, you'll need to push the value into the array. You typically do this using a custom script node or within the logic clause of a loop or processing node.
3. Check for Undefined Error: If you encounter an "undefined" error, it's likely because the array hasn't been initialized properly. Ensure the variable is initialized as an empty array before using functions like
push()
.
Here's a simplified example in pseudocode:
Make sure your logic node or custom script node has access to the variable scope to properly manipulate the array.
If you continue to have issues with this approach, please provide more context or steps that you are following in BuildShip, and I can offer more tailored guidance.
BuildShip AI Support