Map a series of separate fields into an Array (Airtable -> Wordpress)

Hello. I am trying to map a series of fields in AirTable (“Pro 1”, “Pro 2”, “Pro 3” etc) to a Custom Field in Wordpress which is an array.

These are the fields in AirTable:

image

This is where I need to feed these values in:

image

Also - there are up to 5 fields in the source, but not all of them are always populated. Bonus points if I can just create the ones I need based on “are they empty or not”.

Thank you all for your help.

I’m not a pro, but having encountered a similar situation myself recently I came up with the following solution:


It omits an empty string by default as well, so if one of your fields isn’t occupied by any value it’s not included in the array.

Hope this helps for you.

1 Like

Hi Marcel, thank you for your answer.

That’s a clever solution to create an array. Unfortunately even though I have my bundle packaged correctly, I still can’t insert the info in Wordpress. I’m afraid it’s an issue of ACF and “repeater” kind of fields.

Thank you for teaching me this little trick though!

From your picture it seems like the Wordpress module requires a collection within an array input, that might be the reason why it’s not working.

indeed - but I have NO IDEA how to create one

Perhaps you can share some more details of the module you’re trying to insert it into?

I’ll try my best.

I am extracting 5 fields from Airtable (‘Pro 1’, ‘Pro 2’, ‘Pro 3’, ‘Pro 4’, ‘Pro 5’)

I am then trying to insert these into Wordpress. Only this field (and a couple others structured in the same way) don’t work. Whatever I try to import in there, the end result is that field being “empty”.

In the Wordpress module (either create a post or update a post) there is a room for “custom fields”, in which you insert key/value pair.

If this field was flat, I could select “pros” as key and “string” as the value and the field would be successfully populated.

I can manage to create an array of these values (Pro 1-5) but only with the values, not a key/value combo like in the screenshot above.

I really don’t know how to add a key to the array → in the array I only have values.

Could you share a screenshot of your input and the error/output you’re getting?

Well the input has changed 1M times… I tried from using “get variable” to aggregate and its opposite… i tried with JSON…

and the worst is that it does not give any error… simply the field does not get populated.

Could you share a screenshot of your Wordpress module?



This setup seems to work for me. I don’t use Wordpress in any of my workflows, so I’m not entirely sure if this is what you aim to achieve, but reading your replies it just might be.

The iterator creates an array from your Airtable fields (empty fields are omitted) and sends them out as new bundles for each field, then the aggregator adds them to an array with objects with the right target structure. The output of this aggregator module is what you add to the custom field in the Wordpress module.




If you mean to achieve something else, then let me know.

I’ll try!


This is the flow. A record is read in Airtable, where Pro1-5 are 5 text fields.

Second step is the “Set Variable” where I create an array that contains the 5 “pros”.

Here is the results (input/output after the run:)

I have now a variable (called pros_array) which is an array of the 5 pros (one is empty).

The process then looks up the Wordpress ID of the user and creates a post. This step works with no issues.

At this point I add an Iterator: to run through the array. It runs 5 times as expected. These are input/outputs

Now, before we get to the “update post” part, which is where I have an issue, here is how these fields are if I read another post that was inserted manually:

.

Going back to our scenario. It repeats 5 times, here is the input/output of one of these runs:

The input has “pros.pro_line” because pro_line is nested inside “pro” and it’s where each value should go. I tried with just doing “pros” or just “pro_line” but nothing changes. At all.

The output well… it only says “empty” and you can see other fields (not nested) get inserted no problem:

Check out my last post and try adding an aggregator to your flow and set the target structure to the module field that you aim to target (Metadata (custom fields)) for instance.

If that works you can remove the “Set variable” module and directly insert it’s value into the iterator to save some ops.

Hi! thank you for all the help.

I re-created the structure as per your previous post.

This is the output of the array aggregator (which I think is correct):

But by the time it goes to the update wordpress module, and I use it as input, this is the what the result is:

even if I assume [collection] is correct and it’s just not shown, the fields get not populated :frowning:

Make sure you press the “map” button in the Wordpress module

I tried with “map” but it didn’t change anything.
My doubt with “map” is… how does wordpress know what field to update?

we pass an array of “pro_line”, but pro_line should live under “pros” like pros.pro_line

(but also I tried inserting pros.pro_line before and it didn’t work… maybe the . is not the right way to go to nested things?)

Can you enter the values manually and run the scenario, if that gives you the aimed result? If so, run it manually and download the input bundles and take a screenshot of that. That way we can compare it to the mapped input and see where it is going wrong between mapping and manual inputs.

You download the input bundles by pressing the little download dropdown next to “Data size:” in the run summary.

I would not know how to manually input these.

the structure in wordpress is:

pros (array)
bundle 1 (collection) pro_line: text
bundle 2 (collection) pro_line: text

(see picture below).

I would not even know how to manually enter this.

I mean, how are you getting to this result? What are you entering? I can’t look into your scenario, unfortunately and I don’t work with the Wordpress modules more than I did today to try and find a solution for you.