Forum Discussion
Sstein2310
May 10, 2023Copper Contributor
Country column format
Hello community, I have a column with a custom format where the flag of a country and its name is shown, it was working fine and I don't know if it was updates or some problem with the application bu...
Abhijit_Swami1716
Aug 16, 2023Copper Contributor
Could you please share json code for the aboveganeshsanap
ganeshsanap
Aug 16, 2023MVP
Abhijit_Swami1716 Here is the code I used:
{
"$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://www.worldometers.info/img/flags/' + if(indexOf(@currentField,'Afganistan')==0,'af', if(indexOf(@currentField,'Albania')==0,'al',if(indexOf(@currentField,'Alemania')==0,'gm', if(indexOf(@currentField,'Argelia')==0,'ag', if(indexOf(@currentField,'Argentina')==0,'ar', if(indexOf(@currentField,'Andorra')==0,'an', if(indexOf(@currentField,'Antigua y Barbuda')==0,'ac',if(indexOf(@currentField,'Arabia Saudita')==0,'sa',if(indexOf(@currentField,'Zambia')==0,'za',if(indexOf(@currentField,'Zimbabue')==0,'zi','no')))))))))) + '-flag.gif'),'')",
"title": ""
},
"style": {
"max-width": "23px",
"padding": "0 6px 0 0"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}
I have added conditions for only few countries in above JSON. You can add more conditions as per your requirements.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- Abhijit_Swami1716Aug 17, 2023Copper ContributorThank you!