Monday copy Text Column to Country column (requires Country Code)

Hi there,

I have a mini-automation for Monday that requires to take a Text column with a country Name, and copy it to a Country Column (The type of the column is “Country”)

Generally speaking I would use the following operations:

  1. List Board Items (Only the Text column with the country name is needed)
  2. Iterate the results
  3. Set Variables
  • Item ID
  • Country Name
  1. Monday Update Column Values using the Item ID and the Country Name

The twist comes when I need to populate the “Country” Column because it requires a “Country Code” apart from the name:
image

I found online the list of country codes: http://country.io/names.json and I can use the HTTP module to get the content, although I need the to use the “key” and not the “value” in this case…
image

I need some help in figuring out the logic of what to do next, I have a reached a mental dead-end :no_entry_sign: :yum:

You can use the built-in function toArray(Data) to convert it to an array,

then use first(map( )) to filter out the array items by the name, and get the key.

For more information about map, see https://www.make.com/en/help/functions/array-functions#map-complex-array--key--key-for-filtering---possible-values-for-filtering-separated-by-a-comma--

2 Likes

Hi Sam,

Great technical advices and I completed the task ! :innocent:

I honestly don’t understand 100% what I did but here is how the scenario looks like:

HTPP is getting country code from: http://country.io/names.json

Converting the the array:

Monday - List Board Items

Iterating the entries from Monday

Setting the Monday Item ID and Country Name as Variables

Setting the Variable of the Country Code with the country name as the filter

Updating the Monday board with the country name and country code:

Just for the same of interest, what modules I could have saved? or do this scenario in a more efficient way?

You could remove module [12] and put that directly in module [7] “Country Code”, but you need to wrap it with first( ) so that you get the value, and not an array.

2 Likes

OK, done, and working as you suggested:

Recapping to make sure I understand:
Map() takes the Array obtained in Module 11 and provides the “key”, when the “value” equals to the “Country Name” obtained by the variable:
image

If every bundle will include only 1 country name, why do I need the “First()” function?

because map can return more than one matched item (array) - when there is more than one item with the same matched value.

to get the first (or only) item, you still need to call first, or use get to retrieve a specific item from the array.

3 Likes