Vue normale

Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.
À partir d’avant-hierFlux principal

SharePoint Online: Display Country Flags using JSON Formatting – multiple selections

SharePoint Online JSON formatting is a powerful tool that allows users to customize the display of list data, bringing a new level of functionality and aesthetics to SharePoint online lists. In my previous blog post, we saw how to show country flags using SharePoint JSON formatting for single selection choice column.

The JSON formatting sample given in this blog post demonstrates displaying flags of the counties selected in the multiple selection SharePoint choice column.

The country flags are shown using the FlagCDN – CDN & API of flags web site API. As Microsoft have blocked the external domain images in SharePoint JSON formatting by default, you will have to allow the flagcdn.com domain in HTML Field Security settings of your SharePoint site by following this step by step guide: Why external domain image URLs are not working in SharePoint Online JSON Formatting?

Also, You can find the list of countries used in this JSON sample at: List of Countries.

Multiple selection choice column settings

Add list of countries in the choice column settings like:

Multiple selection SharePoint choice column settings

SharePoint Online JSON sample

Use below JSON to apply JSON column formatting for multiple selection SharePoint choice column to show the flag of selected countries:

{
	"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
	"elmType": "div",
	"inlineEditField": "[$Countries]",
	"children": [
		{
			"elmType": "div",
			"style": {
				"display": "flex",
				"flex-direction": "column",
				"justify-content": "flex-start",
				"flex-wrap": "wrap",
				"margin": "5px 0px"
			},
			"children": [
				{
					"elmType": "div",
					"forEach": "choiceIterator in @currentField",
					"style": {
						"margin": "3px 0px",
						"display": "flex",
						"flex-direction": "row",
						"align-items": "center"
					},
					"children": [
						{
							"elmType": "img",
							"attributes": {
								"src": "=if([$choiceIterator],'https://flagcdn.com/w550/' + if([$choiceIterator]=='Afghanistan','af',if([$choiceIterator]=='Albania','al',if([$choiceIterator]=='Algeria','dz',if([$choiceIterator]=='American Samoa','as',if([$choiceIterator]=='Andorra','ad',if([$choiceIterator]=='Angola','ao',if([$choiceIterator]=='Anguilla','ai',if([$choiceIterator]=='Antarctica','aq',if([$choiceIterator]=='Antigua and Barbuda','ag',if([$choiceIterator]=='Argentina','ar',if([$choiceIterator]=='Armenia','am',if([$choiceIterator]=='Aruba','aw',if([$choiceIterator]=='Australia','au',if([$choiceIterator]=='Austria','at',if([$choiceIterator]=='Azerbaijan','az',if([$choiceIterator]=='Bahamas','bs',if([$choiceIterator]=='Bahrain','bh',if([$choiceIterator]=='Bangladesh','bd',if([$choiceIterator]=='Barbados','bb',if([$choiceIterator]=='Belarus','by',if([$choiceIterator]=='Belgium','be',if([$choiceIterator]=='Belize','bz',if([$choiceIterator]=='Benin','bj',if([$choiceIterator]=='Bermuda','bm',if([$choiceIterator]=='Bhutan','bt',if([$choiceIterator]=='Bolivia','bo',if([$choiceIterator]=='Bonaire','bq',if([$choiceIterator]=='Bosnia and Herzegovina','ba',if([$choiceIterator]=='Botswana','bw',if([$choiceIterator]=='Bouvet Island','bv',if([$choiceIterator]=='Brazil','br',if([$choiceIterator]=='British Indian Ocean Territory','io',if([$choiceIterator]=='Brunei','bn',if([$choiceIterator]=='Bulgaria','bg',if([$choiceIterator]=='Burkina Faso','bf',if([$choiceIterator]=='Burundi','bi',if([$choiceIterator]=='Cambodia','kh',if([$choiceIterator]=='Cameroon','cm',if([$choiceIterator]=='Canada','ca',if([$choiceIterator]=='Cape Verde','cv',if([$choiceIterator]=='Cayman Islands','ky',if([$choiceIterator]=='Central African Republic','cf',if([$choiceIterator]=='Chad','td',if([$choiceIterator]=='Chile','cl',if([$choiceIterator]=='China','cn',if([$choiceIterator]=='Christmas Island','cx',if([$choiceIterator]=='Cocos (Keeling) Islands','cc',if([$choiceIterator]=='Colombia','co',if([$choiceIterator]=='Comoros','km',if([$choiceIterator]=='Democratic Republic of the Congo','cd',if([$choiceIterator]=='Cook Islands','ck',if([$choiceIterator]=='Costa Rica','cr',if([$choiceIterator]=='Croatia','hr',if([$choiceIterator]=='Cuba','cu',if([$choiceIterator]=='Cyprus','cy',if([$choiceIterator]=='Czech Republic','cz',if([$choiceIterator]=='Denmark','dk',if([$choiceIterator]=='Djibouti','dj',if([$choiceIterator]=='Dominica','dm',if([$choiceIterator]=='Dominican Republic','do',if([$choiceIterator]=='Ecuador','ec',if([$choiceIterator]=='Egypt','eg',if([$choiceIterator]=='El Salvador','sv',if([$choiceIterator]=='Equatorial Guinea','gq',if([$choiceIterator]=='Eritrea','er',if([$choiceIterator]=='Estonia','ee',if([$choiceIterator]=='Ethiopia','et',if([$choiceIterator]=='Falkland Islands (Malvinas)','fk',if([$choiceIterator]=='Faroe Islands','fo',if([$choiceIterator]=='Fiji','fj',if([$choiceIterator]=='Finland','fi',if([$choiceIterator]=='France','fr',if([$choiceIterator]=='French Guiana','gf',if([$choiceIterator]=='French Polynesia','pf',if([$choiceIterator]=='French Southern Territories','tf',if([$choiceIterator]=='Gabon','ga',if([$choiceIterator]=='Gambia','gm',if([$choiceIterator]=='Georgia','ge',if([$choiceIterator]=='Germany','de',if([$choiceIterator]=='Ghana','gh',if([$choiceIterator]=='Gibraltar','gi',if([$choiceIterator]=='Greece','gr',if([$choiceIterator]=='Greenland','gl',if([$choiceIterator]=='Grenada','gd',if([$choiceIterator]=='Guadeloupe','gp',if([$choiceIterator]=='Guam','gu',if([$choiceIterator]=='Guatemala','gt',if([$choiceIterator]=='Guernsey','gg',if([$choiceIterator]=='Guinea','gn',if([$choiceIterator]=='Guinea-Bissau','gw',if([$choiceIterator]=='Guyana','gy',if([$choiceIterator]=='Haiti','ht',if([$choiceIterator]=='Heard Island and McDonald Islands','hm',if([$choiceIterator]=='Honduras','hn',if([$choiceIterator]=='Hong Kong','hk',if([$choiceIterator]=='Hungary','hu',if([$choiceIterator]=='Iceland','is',if([$choiceIterator]=='India','in',if([$choiceIterator]=='Indonesia','id',if([$choiceIterator]=='Iran','ir',if([$choiceIterator]=='Iraq','iq',if([$choiceIterator]=='Ireland','ie',if([$choiceIterator]=='Isle of Man','im',if([$choiceIterator]=='Israel','il',if([$choiceIterator]=='Italy','it',if([$choiceIterator]=='Jamaica','jm',if([$choiceIterator]=='Japan','jp',if([$choiceIterator]=='Jersey','je',if([$choiceIterator]=='Jordan','jo',if([$choiceIterator]=='Kazakhstan','kz',if([$choiceIterator]=='Kenya','ke',if([$choiceIterator]=='Kiribati','ki',if([$choiceIterator]=='North Korea','kp',if([$choiceIterator]=='South Korea','kr',if([$choiceIterator]=='Kuwait','kw',if([$choiceIterator]=='Kyrgyzstan','kg',if([$choiceIterator]=='Laos','la',if([$choiceIterator]=='Latvia','lv',if([$choiceIterator]=='Lebanon','lb',if([$choiceIterator]=='Lesotho','ls',if([$choiceIterator]=='Liberia','lr',if([$choiceIterator]=='Libya','ly',if([$choiceIterator]=='Liechtenstein','li',if([$choiceIterator]=='Lithuania','lt',if([$choiceIterator]=='Luxembourg','lu',if([$choiceIterator]=='Macao','mo',if([$choiceIterator]=='North Macedonia','mk',if([$choiceIterator]=='Madagascar','mg',if([$choiceIterator]=='Malawi','mw',if([$choiceIterator]=='Malaysia','my',if([$choiceIterator]=='Maldives','mv',if([$choiceIterator]=='Mali','ml',if([$choiceIterator]=='Malta','mt',if([$choiceIterator]=='Marshall Islands','mh',if([$choiceIterator]=='Martinique','mq',if([$choiceIterator]=='Mauritania','mr',if([$choiceIterator]=='Mauritius','mu',if([$choiceIterator]=='Mayotte','yt',if([$choiceIterator]=='Mexico','mx',if([$choiceIterator]=='Micronesia','fm',if([$choiceIterator]=='Moldova','md',if([$choiceIterator]=='Monaco','mc',if([$choiceIterator]=='Mongolia','mn',if([$choiceIterator]=='Montenegro','me',if([$choiceIterator]=='Montserrat','ms',if([$choiceIterator]=='Morocco','ma',if([$choiceIterator]=='Mozambique','mz',if([$choiceIterator]=='Myanmar','mm',if([$choiceIterator]=='Namibia','na',if([$choiceIterator]=='Nauru','nr',if([$choiceIterator]=='Nepal','np',if([$choiceIterator]=='Netherlands','nl',if([$choiceIterator]=='New Caledonia','nc',if([$choiceIterator]=='New Zealand','nz',if([$choiceIterator]=='Nicaragua','ni',if([$choiceIterator]=='Niger','ne',if([$choiceIterator]=='Nigeria','ng',if([$choiceIterator]=='Niue','nu',if([$choiceIterator]=='Norfolk Island','nf',if([$choiceIterator]=='Northern Mariana Islands','mp',if([$choiceIterator]=='Norway','no',if([$choiceIterator]=='Oman','om',if([$choiceIterator]=='Pakistan','pk',if([$choiceIterator]=='Palau','pw',if([$choiceIterator]=='Palestine','ps',if([$choiceIterator]=='Panama','pa',if([$choiceIterator]=='Papua New Guinea','pg',if([$choiceIterator]=='Paraguay','py',if([$choiceIterator]=='Peru','pe',if([$choiceIterator]=='Philippines','ph',if([$choiceIterator]=='Pitcairn','pn',if([$choiceIterator]=='Poland','pl',if([$choiceIterator]=='Portugal','pt',if([$choiceIterator]=='Puerto Rico','pr',if([$choiceIterator]=='Qatar','qa',if([$choiceIterator]=='Romania','ro',if([$choiceIterator]=='Russia','ru',if([$choiceIterator]=='Rwanda','rw',if([$choiceIterator]=='Saint Barthélemy','bl',if([$choiceIterator]=='Saint Helena, Ascension and Tristan da Cunha','sh',if([$choiceIterator]=='Saint Kitts and Nevis','kn',if([$choiceIterator]=='Saint Lucia','lc',if([$choiceIterator]=='Saint Martin','mf',if([$choiceIterator]=='Saint Pierre and Miquelon','pm',if([$choiceIterator]=='Saint Vincent and the Grenadines','vc',if([$choiceIterator]=='Samoa','ws',if([$choiceIterator]=='San Marino','sm',if([$choiceIterator]=='Sao Tome and Principe','st',if([$choiceIterator]=='Saudi Arabia','sa',if([$choiceIterator]=='Senegal','sn',if([$choiceIterator]=='Serbia','rs',if([$choiceIterator]=='Seychelles','sc',if([$choiceIterator]=='Sierra Leone','sl',if([$choiceIterator]=='Singapore','sg',if([$choiceIterator]=='Sint Maarten','sx',if([$choiceIterator]=='Slovakia','sk',if([$choiceIterator]=='Slovenia','si',if([$choiceIterator]=='Solomon Islands','sb',if([$choiceIterator]=='Somalia','so',if([$choiceIterator]=='South Africa','za',if([$choiceIterator]=='South Georgia and the South Sandwich Islands','gs',if([$choiceIterator]=='South Sudan','ss',if([$choiceIterator]=='Spain','es',if([$choiceIterator]=='Sri Lanka','lk',if([$choiceIterator]=='Sudan','sd',if([$choiceIterator]=='Suriname','sr',if([$choiceIterator]=='Svalbard and Jan Mayen','sj',if([$choiceIterator]=='Swaziland','sz',if([$choiceIterator]=='Sweden','se',if([$choiceIterator]=='Switzerland','ch',if([$choiceIterator]=='Syria','sy',if([$choiceIterator]=='Taiwan','tw',if([$choiceIterator]=='Tajikistan','tj',if([$choiceIterator]=='Tanzania','tz',if([$choiceIterator]=='Thailand','th',if([$choiceIterator]=='Timor-Leste','tl',if([$choiceIterator]=='Togo','tg',if([$choiceIterator]=='Tokelau','tk',if([$choiceIterator]=='Tonga','to',if([$choiceIterator]=='Trinidad and Tobago','tt',if([$choiceIterator]=='Tunisia','tn',if([$choiceIterator]=='Turkey','tr',if([$choiceIterator]=='Turkmenistan','tm',if([$choiceIterator]=='Turks and Caicos Islands','tc',if([$choiceIterator]=='Tuvalu','tv',if([$choiceIterator]=='Uganda','ug',if([$choiceIterator]=='Ukraine','ua',if([$choiceIterator]=='United Arab Emirates','ae',if([$choiceIterator]=='United Kingdom','gb',if([$choiceIterator]=='United States','us',if([$choiceIterator]=='United States Minor Outlying Islands','um',if([$choiceIterator]=='Uruguay','uy',if([$choiceIterator]=='Uzbekistan','uz',if([$choiceIterator]=='Vanuatu','vu',if([$choiceIterator]=='Vatican City','va',if([$choiceIterator]=='Venezuela','ve',if([$choiceIterator]=='Viet Nam','vn',if([$choiceIterator]=='British Virgin Islands','vg',if([$choiceIterator]=='United States Virgin Islands','vi',if([$choiceIterator]=='Wallis and Futuna','wf',if([$choiceIterator]=='Western Sahara','eh',if([$choiceIterator]=='Yemen','ye',if([$choiceIterator]=='Zambia','zm',if([$choiceIterator]=='Zimbabwe','zw','')))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) + '.png','')",
								"title": ""
							},
							"style": {
								"max-width": "50px",
								"padding": "0 10px 0 0"
							}
						},
						{
							"elmType": "span",
							"txtContent": "[$choiceIterator]"
						}
					]
				}
			]
		}
	]
}

Where [$Countries] is the internal name of SharePoint choice column. You can get the internal name of your SharePoint list column by following this article: How to find the Internal name of columns in SharePoint Online?

Output

Multiple selection SharePoint choice column showing country flags using SharePoint online JSON formatting
Displaying country flags using SharePoint JSON formatting

Learn more

SharePoint Online: Display Country Flags using JSON Formatting

SharePoint Online JSON formatting is a powerful tool that allows users to customize the display of list data, bringing a new level of functionality and aesthetics to SharePoint online lists. In this blog post, we’ll explore an exciting and educational application of JSON formatting for displaying country flags within SharePoint lists.

The JSON formatting sample given in this blog post demonstrates displaying flags of the counties selected in the single selection SharePoint choice column.

The country flags are shown using the FlagCDN – CDN & API of flags web site API. As Microsoft have blocked the external domain images in SharePoint JSON formatting by default, you will have to allow the flagcdn.com domain in HTML Field Security settings of your SharePoint site by following this step by step guide: Why external domain image URLs are not working in SharePoint Online JSON Formatting?

Also, You can find the list of countries used in this JSON sample at: List of Countries.

Single selection choice column settings

Add list of countries in the choice column settings like:

Single selection SharePoint choice column settings to display country flags using SharePoint online JSON formatting
Single selection SharePoint choice column settings

SharePoint Online JSON sample

Use below JSON to apply JSON column formatting for single selection SharePoint choice column to show the flag of selected country:

{
	"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
	"elmType": "div",
	"inlineEditField": "[$Country]",
	"children": [
		{
			"elmType": "img",
			"attributes": {
				"src": "=if(@currentField,'https://flagcdn.com/w550/' + if(@currentField=='Afghanistan','af',if(@currentField=='Albania','al',if(@currentField=='Algeria','dz',if(@currentField=='American Samoa','as',if(@currentField=='Andorra','ad',if(@currentField=='Angola','ao',if(@currentField=='Anguilla','ai',if(@currentField=='Antarctica','aq',if(@currentField=='Antigua and Barbuda','ag',if(@currentField=='Argentina','ar',if(@currentField=='Armenia','am',if(@currentField=='Aruba','aw',if(@currentField=='Australia','au',if(@currentField=='Austria','at',if(@currentField=='Azerbaijan','az',if(@currentField=='Bahamas','bs',if(@currentField=='Bahrain','bh',if(@currentField=='Bangladesh','bd',if(@currentField=='Barbados','bb',if(@currentField=='Belarus','by',if(@currentField=='Belgium','be',if(@currentField=='Belize','bz',if(@currentField=='Benin','bj',if(@currentField=='Bermuda','bm',if(@currentField=='Bhutan','bt',if(@currentField=='Bolivia','bo',if(@currentField=='Bonaire','bq',if(@currentField=='Bosnia and Herzegovina','ba',if(@currentField=='Botswana','bw',if(@currentField=='Bouvet Island','bv',if(@currentField=='Brazil','br',if(@currentField=='British Indian Ocean Territory','io',if(@currentField=='Brunei','bn',if(@currentField=='Bulgaria','bg',if(@currentField=='Burkina Faso','bf',if(@currentField=='Burundi','bi',if(@currentField=='Cambodia','kh',if(@currentField=='Cameroon','cm',if(@currentField=='Canada','ca',if(@currentField=='Cape Verde','cv',if(@currentField=='Cayman Islands','ky',if(@currentField=='Central African Republic','cf',if(@currentField=='Chad','td',if(@currentField=='Chile','cl',if(@currentField=='China','cn',if(@currentField=='Christmas Island','cx',if(@currentField=='Cocos (Keeling) Islands','cc',if(@currentField=='Colombia','co',if(@currentField=='Comoros','km',if(@currentField=='Democratic Republic of the Congo','cd',if(@currentField=='Cook Islands','ck',if(@currentField=='Costa Rica','cr',if(@currentField=='Croatia','hr',if(@currentField=='Cuba','cu',if(@currentField=='Cyprus','cy',if(@currentField=='Czech Republic','cz',if(@currentField=='Denmark','dk',if(@currentField=='Djibouti','dj',if(@currentField=='Dominica','dm',if(@currentField=='Dominican Republic','do',if(@currentField=='Ecuador','ec',if(@currentField=='Egypt','eg',if(@currentField=='El Salvador','sv',if(@currentField=='Equatorial Guinea','gq',if(@currentField=='Eritrea','er',if(@currentField=='Estonia','ee',if(@currentField=='Ethiopia','et',if(@currentField=='Falkland Islands (Malvinas)','fk',if(@currentField=='Faroe Islands','fo',if(@currentField=='Fiji','fj',if(@currentField=='Finland','fi',if(@currentField=='France','fr',if(@currentField=='French Guiana','gf',if(@currentField=='French Polynesia','pf',if(@currentField=='French Southern Territories','tf',if(@currentField=='Gabon','ga',if(@currentField=='Gambia','gm',if(@currentField=='Georgia','ge',if(@currentField=='Germany','de',if(@currentField=='Ghana','gh',if(@currentField=='Gibraltar','gi',if(@currentField=='Greece','gr',if(@currentField=='Greenland','gl',if(@currentField=='Grenada','gd',if(@currentField=='Guadeloupe','gp',if(@currentField=='Guam','gu',if(@currentField=='Guatemala','gt',if(@currentField=='Guernsey','gg',if(@currentField=='Guinea','gn',if(@currentField=='Guinea-Bissau','gw',if(@currentField=='Guyana','gy',if(@currentField=='Haiti','ht',if(@currentField=='Heard Island and McDonald Islands','hm',if(@currentField=='Honduras','hn',if(@currentField=='Hong Kong','hk',if(@currentField=='Hungary','hu',if(@currentField=='Iceland','is',if(@currentField=='India','in',if(@currentField=='Indonesia','id',if(@currentField=='Iran','ir',if(@currentField=='Iraq','iq',if(@currentField=='Ireland','ie',if(@currentField=='Isle of Man','im',if(@currentField=='Israel','il',if(@currentField=='Italy','it',if(@currentField=='Jamaica','jm',if(@currentField=='Japan','jp',if(@currentField=='Jersey','je',if(@currentField=='Jordan','jo',if(@currentField=='Kazakhstan','kz',if(@currentField=='Kenya','ke',if(@currentField=='Kiribati','ki',if(@currentField=='North Korea','kp',if(@currentField=='South Korea','kr',if(@currentField=='Kuwait','kw',if(@currentField=='Kyrgyzstan','kg',if(@currentField=='Laos','la',if(@currentField=='Latvia','lv',if(@currentField=='Lebanon','lb',if(@currentField=='Lesotho','ls',if(@currentField=='Liberia','lr',if(@currentField=='Libya','ly',if(@currentField=='Liechtenstein','li',if(@currentField=='Lithuania','lt',if(@currentField=='Luxembourg','lu',if(@currentField=='Macao','mo',if(@currentField=='North Macedonia','mk',if(@currentField=='Madagascar','mg',if(@currentField=='Malawi','mw',if(@currentField=='Malaysia','my',if(@currentField=='Maldives','mv',if(@currentField=='Mali','ml',if(@currentField=='Malta','mt',if(@currentField=='Marshall Islands','mh',if(@currentField=='Martinique','mq',if(@currentField=='Mauritania','mr',if(@currentField=='Mauritius','mu',if(@currentField=='Mayotte','yt',if(@currentField=='Mexico','mx',if(@currentField=='Micronesia','fm',if(@currentField=='Moldova','md',if(@currentField=='Monaco','mc',if(@currentField=='Mongolia','mn',if(@currentField=='Montenegro','me',if(@currentField=='Montserrat','ms',if(@currentField=='Morocco','ma',if(@currentField=='Mozambique','mz',if(@currentField=='Myanmar','mm',if(@currentField=='Namibia','na',if(@currentField=='Nauru','nr',if(@currentField=='Nepal','np',if(@currentField=='Netherlands','nl',if(@currentField=='New Caledonia','nc',if(@currentField=='New Zealand','nz',if(@currentField=='Nicaragua','ni',if(@currentField=='Niger','ne',if(@currentField=='Nigeria','ng',if(@currentField=='Niue','nu',if(@currentField=='Norfolk Island','nf',if(@currentField=='Northern Mariana Islands','mp',if(@currentField=='Norway','no',if(@currentField=='Oman','om',if(@currentField=='Pakistan','pk',if(@currentField=='Palau','pw',if(@currentField=='Palestine','ps',if(@currentField=='Panama','pa',if(@currentField=='Papua New Guinea','pg',if(@currentField=='Paraguay','py',if(@currentField=='Peru','pe',if(@currentField=='Philippines','ph',if(@currentField=='Pitcairn','pn',if(@currentField=='Poland','pl',if(@currentField=='Portugal','pt',if(@currentField=='Puerto Rico','pr',if(@currentField=='Qatar','qa',if(@currentField=='Romania','ro',if(@currentField=='Russia','ru',if(@currentField=='Rwanda','rw',if(@currentField=='Saint Barthélemy','bl',if(@currentField=='Saint Helena, Ascension and Tristan da Cunha','sh',if(@currentField=='Saint Kitts and Nevis','kn',if(@currentField=='Saint Lucia','lc',if(@currentField=='Saint Martin','mf',if(@currentField=='Saint Pierre and Miquelon','pm',if(@currentField=='Saint Vincent and the Grenadines','vc',if(@currentField=='Samoa','ws',if(@currentField=='San Marino','sm',if(@currentField=='Sao Tome and Principe','st',if(@currentField=='Saudi Arabia','sa',if(@currentField=='Senegal','sn',if(@currentField=='Serbia','rs',if(@currentField=='Seychelles','sc',if(@currentField=='Sierra Leone','sl',if(@currentField=='Singapore','sg',if(@currentField=='Sint Maarten','sx',if(@currentField=='Slovakia','sk',if(@currentField=='Slovenia','si',if(@currentField=='Solomon Islands','sb',if(@currentField=='Somalia','so',if(@currentField=='South Africa','za',if(@currentField=='South Georgia and the South Sandwich Islands','gs',if(@currentField=='South Sudan','ss',if(@currentField=='Spain','es',if(@currentField=='Sri Lanka','lk',if(@currentField=='Sudan','sd',if(@currentField=='Suriname','sr',if(@currentField=='Svalbard and Jan Mayen','sj',if(@currentField=='Swaziland','sz',if(@currentField=='Sweden','se',if(@currentField=='Switzerland','ch',if(@currentField=='Syria','sy',if(@currentField=='Taiwan','tw',if(@currentField=='Tajikistan','tj',if(@currentField=='Tanzania','tz',if(@currentField=='Thailand','th',if(@currentField=='Timor-Leste','tl',if(@currentField=='Togo','tg',if(@currentField=='Tokelau','tk',if(@currentField=='Tonga','to',if(@currentField=='Trinidad and Tobago','tt',if(@currentField=='Tunisia','tn',if(@currentField=='Turkey','tr',if(@currentField=='Turkmenistan','tm',if(@currentField=='Turks and Caicos Islands','tc',if(@currentField=='Tuvalu','tv',if(@currentField=='Uganda','ug',if(@currentField=='Ukraine','ua',if(@currentField=='United Arab Emirates','ae',if(@currentField=='United Kingdom','gb',if(@currentField=='United States','us',if(@currentField=='United States Minor Outlying Islands','um',if(@currentField=='Uruguay','uy',if(@currentField=='Uzbekistan','uz',if(@currentField=='Vanuatu','vu',if(@currentField=='Vatican City','va',if(@currentField=='Venezuela','ve',if(@currentField=='Viet Nam','vn',if(@currentField=='British Virgin Islands','vg',if(@currentField=='United States Virgin Islands','vi',if(@currentField=='Wallis and Futuna','wf',if(@currentField=='Western Sahara','eh',if(@currentField=='Yemen','ye',if(@currentField=='Zambia','zm',if(@currentField=='Zimbabwe','zw','')))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) + '.png','')",
				"title": ""
			},
			"style": {
				"max-width": "50px",
				"padding": "0 10px 0 0"
			}
		},
		{
			"elmType": "span",
			"txtContent": "@currentField"
		}
	]
}

Where [$Country] is the internal name of SharePoint choice column. You can get the internal name of your SharePoint list column by following this article: How to find the Internal name of columns in SharePoint Online?

Output

Single selection SharePoint choice column showing country flags using SharePoint online JSON formatting
Displaying country flags using SharePoint JSON formatting

Learn more

SharePoint Online: External Image URLs not working in JSON Formatting

SharePoint Online is a powerful collaboration and content management platform that empowers organizations to create, manage, and share information seamlessly. JSON formatting in SharePoint online allows users to customize the look and feel of the columns, views and forms in their SharePoint lists and libraries.

Earlier this year Microsoft updated the SharePoint JSON formatting feature and blocked most of the external domain image sources by default in custom JSON column and view formatting.

Only images from the following domains are allowed by default:

  • tenant domain, configured multi-geo domains and vanity domains (company.sharepoint.com)
  • cdn.office.net, akamaihd.net, static2.sharepointonline.com CDNs

The Solution – Modifying HTML Field Security Settings:

To address the challenge of displaying external web site domain images in JSON formatting, one effective solution is to adjust the HTML field security settings of your SharePoint site. This involves whitelisting trusted external domains or CDNs to allow their images to be displayed within your SharePoint environment. Follow these steps to implement the solution:

1. Go to your SharePoint online site.

2. Click on Settings (gear) icon from top right corner and select Site information.

3. Click on View all site settings link from Site information panel, it will open the SharePoint site settings page.

4. Under the Site Collection Administration section, locate and click on the HTML Field Security settings link.

5. Select Allow contributors to insert iframes only from the following domains, add external web site domain from where you are using the images under Allow iframes from this domain text box and click Add button.

6. Click OK button at the bottom of HTML Field Security settings page to save the changes.

Allow external site domain from SharePoint HTML Field Security settings

7. Navigate back to the SharePoint list where you are using external image with JSON formatting and refresh the web page. Now, you should see that the external images are working using the SharePoint Online JSON formatting.

Output

Before adding external site domain to SharePoint HTML Field Security Settings:

External Image URLs are not working in SharePoint Online JSON formatting
External Image URLs are not working in SharePoint Online JSON formatting

After adding external site domain to SharePoint HTML Field Security Settings:

External Image URLs are working in SharePoint Online JSON formatting after adding external web site domain to SharePoint HTML Field Security settings
Working External Image URLs in SharePoint Online JSON formatting

Learn more

❌
❌