Hi, this is my first post here. Apologies if this is super-basic but I’m struggling with converting a simple comma-delimited list to an array object. What I have now:
I’m a bit out of my technical depth with this. Can anyone point me in the right direction of how I can massage that comma-delim list into an array object I can pass along?
Hi, so I tried a different approach here using visual nodes instead of code and I feel like I’m close but still struggling. Here’s a loom that shows what I’m doing:
You can break up a string into an array using the split() operation. You can use it in an expression like this. (I also added an example of then converting the array into items in case you need that).
Let me know if this solves the issue, or if you also need help with your second approach?
@bartv thx so much for pointing me to the split() function. That got it into the expected format that the HTTPpost wants but I need to do essentially a substitution from a lookup table to replace those string names with their database ID’s. I know how i would do this in Google Sheets via vLookup. Do you know of any equivalent function or node type in n8n that can accomplish this substitution keyed off the name as the join field?
This shows you where I’m at with things and this is the last piece to work out to put this to bed:
I’ve been going through the Level 2 tutorial on a merging scenario but I’m missing something in how to match my fields against each other. Something is off with my data types and I don’t grasp the dot.notation syntax and javascript array stuff well enough yet to see what the issue is.
Thanks for any tips you may have at this point.
sean
Hi, just thought I’d close the loop on this and show the solution I came up with to finally finish this. Unfortunately I never figured out the vLookup equivalent in n8n (I’m sure there’s a clever way to accomplish the same thing either in code or with a chain of nodes but it was beyond me so I just did this hack):
In Google Sheets I have the lookup table on a separate sheet:
I made a new column in the sheet with the people data called SDGS BY ID, copied the named SDGs and then did a find/replace one-by-one for all 17 SDGs on that column in the Gsheet. That yielded what I needed in terms of a field that had a comma-delim list of the database ID’s for each SDG for that person. I did have to do a find/replace to eliminate the space after the comma to get it to work.
Not a very elegant/resilient solution but I only needed a one-time import vs. an ongoing sync operation so this was adequate to get what I needed. If anyone knows how to move that lookup table logic into n8n itself eliminating the find/replace tapdance to get the database ID’s, I would love to see that in action. Hope this helps someone.