Images for country flag - API

This is just for the purpose of sharing a tips and tricks to decorate your app where you do have master table/data in connection with ‘countries’ globally and then wish to display ‘Country Flag’ based on each country.

Hope this will be found useful for those who might have been looking for a trick to make your life easier.
This does not require any coding knowledge (like Javascript, HTML, CSS, python whatsoever) at all.

First of all, see the screenshot below.

Some of my app has a master table for the name of the city, port and name of the country. To deliver quicker insight to the user, image or thumbnail of country flag should be a good tool to put in place on the app view. The example is showing American flag, as the selected city is associated with Seattle (Apphseet locates!!!) . One possible way to achieve this is to append the url to the country flag (url available in public) and manually attach to each row. Yes, it is feasible, but it probably take forever.

If you have ISO country code (2 digit) on your data table, you are already reaching to the goal. Even for those who does not have ISO country code, but perfect list of the country name, then you probably can mix and blend the data to associate your country name column with ISO country code instantly.

Anyway, this free api I found after asking to Google would solve and help us.

https://www.countryflags.io/

Using ISO country code parameter, then we are able to get the image of the selected country so easily.

Let me move on with another screenshot.

If you have ISO country code, again, you dont need to take action for the data preparation side. (This screenshot shows single row of the table have column for country ID (ISO).
If your data does not have ISO country code, then you can ask Mr (or Ms) Google to get the list.
(https://countrycode.org/)

Once your data have column for country code, then ready to move to the next step.

Within your table, generate VC (virtual column) with name whatever you like. Then put a App formula using country flag api.

See the above screenshot which is telling how and what we need to put into app formula.

This is full strings for the app formula.

https://www.countryflags.io/"&[Country]&"/flat/64.png

On this example, i do have column name “Country” where we store ISO country code. Regardless of the name assigned to the ISO country name column, please contac the string like this example so that you can get the full path, which is equal to the URL for API ‘GET’ call.

This particular virtual column data type should be set either IMAGE or THUMBNAIL.

Basically that’s it, thanks God.

Now each independent and separate row of the table will dynamically generate the country flag Image and will be able to display within Appsheet view.

Hope this quick and easy tips will bring a ‘peace’ all over the world.

Thanks for your attention.

Koichi Tsuji

21 12 16.2K
12 REPLIES 12

MultiTech
Participant V

One word: epic.

Very cool & useful!! Thank you Sir!

The external service I introduced on this post seems to stop their free services. No longer the URL will work.

As alternative service which does the exactly same jobs for us, we found this.

https://flagicons.lipis.dev/

Place the Country Code column and value in your table, and create virtual column using expression like this.

https://flagicons.lipis.dev/flags/4x3/’&lower([Country Code])&’.svg’

The important point is we need to wrap the country code by Lower() as capital country code seems not to work.

@Takuya_Miyai

@MultiTech_Visions

Hi @tsuji_koichi , It does not work ?

3X_8_3_832f823ab5775f947351b054a32849ed01ba1b15.png


Thanks!

@Phong_Lam You wrote it wrong with just copy-n-paste
Try

CONCATENATE(
  "https://flagicons.lipis.dev/flags/4x3/",
  LOWER([Country Code]),
  ".svg"
)

Thanks @SkrOYC , excellent !

Hi , I tried it, It work in the main viewm but not in ref view, do you know how can I fix It ? I create a table named country with country code and contry flag (use above expression) as label . On other view , presale table , have a country column, I ref It with country table, but the image (flag) have error…

Could you try by replacing the formula with the following?

CONCATENATE(
  "https://www.countryflags.io/",
  [Country Code],
  "/flat/64.png"
)

3X_5_f_5f407130c0d82038f97191de6aac606b02e0f3e9.png

It stil not work

Paste this instead to test:

https://ppaas.herokuapp.com/partyparrot/mega?delay=50

It’s working with this one now @SkrOYC , may be because of sync problem…

For the one that have error, I have to re-edit , then it will show the image. That the old data before I made the ref on country column.

Got it. So it was a cache problem

Top Labels in this Space