How to populate list of Countries with 3 letter code as value in dropdown field? | Community
Skip to main content
sesmic
Level 4
July 14, 2023
Solved

How to populate list of Countries with 3 letter code as value in dropdown field?

  • July 14, 2023
  • 1 reply
  • 2224 views

Hi everyone,
I'm working on Adaptive form in which I've dropdown for Country Names. Now, I want to populate the list of full country name, but the values should be their 3-letter code. Something like below.

 

<option value="AZE">Azerbaijan</option> <option value="AUS">Australia</option>

 

Adding 105 items manually to the dropdown field is lengthy. So, I tried Function Output feature of AF but I can only populate country names without their codes like below:

 

<option value="United States">United States</option> <option value="Norway">Norway</option>

Got above output by using this:

const countryList = [ "Afghanistan", "Albania", "Algeria", "American Samoa"];

But can't leverage this:

const countryListAlpha3 = { "AFG": "Afghanistan", "ALB": "Albania", "DZA": "Algeria"};

Using country list from this (line 528 have 3-letter codes) GitHub link. I'm not sure how to add value to dropdown items.

Can someone please help me to accomplish this?

Regards,
Sesmic

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by workflowuser

here is a link to live example of the capability

https://forms.enablementadobe.com/content/dam/formsanddocuments/cascadingdropdrop/jcr:content?wcmmode=disabled

1 reply

Adobe Employee
July 14, 2023

you can use publicly available API to get the list of countries and populate the drop-down list

I have written an article on this

https://experienceleague.adobe.com/docs/experience-manager-learn/forms/some-useful-integrations/geonames-org.html?lang=en

 

let me know if you have trouble getting this to work on your system

sesmic
sesmicAuthor
Level 4
July 14, 2023

Hi @workflowuser 
Thanks for the reply!
I read your article while learning AF and implemented it. Felt awesome🔥.
But, in current use case there's no dependent DropDownList just country names. I simply want list of countries with their codes as value because the submitted value is important after submission. 

Adobe Employee
July 14, 2023

you can follow the article to implement a form data model service to fetch the countries list from any of the publicly available api

https://www.universal-tutorial.com/rest-apis/free-rest-api-for-country-state-city

 

This API returns the countries and code associated with it

lets have a call

send a private message