How to convert CA into abbreviation state name

Hi All,

Please help me with this
My input string should be in short form that looks like CA
How can I convert CA into an abbreviation State name for example? CA for California, AK for Alaska.

Thanks
Farhan

@Farhan

Create one excel file with abbreviation and its corresponding state name. Then you can refer this file to get the state name based on given abbreviation.

2 Likes

An improvisation to this is retrieving abbreviation - state name from Wikipedia or any other stable web sites and search for the abbreviation.
In this sense, If there is any addition/change in the details, No need of manual update in the system.

You could use the attached code. Send InAbbreviation argument to provide the Abbreviation and get the State Name from the OutState argument.

StatesAbbreviation.xaml (15.5 KB)

Hope it helps.!

2 Likes

Thank you UiJack, the code works perfectly.

I know this is super late, but another approach can be reading the abbreviations from an excel or fetching it from wikipedia, storing that data into a dictionary, and simply calling the dictionary for that state.

I know the thread is a little old but I was searching for an existing solution rather than spend the required time building one from scratch and I landed here. My use case was the reverse, I had a list of state names and needed the abbreviation but figured the most time consuming part was defining the data and would simply modify the activity to meet my needs.

Since UIJack’s solution helped me I wanted to give back in case someone else can benefit. I extended UIJack’s solution by making it so that if you pass in a valid abbreviation you will get back the state name (like the original activity) but if you pass in a full state name (valid of course) then you get back the abbreviation. Simply pass either/or and get back the matching companion value.
StatesAbbreviation.xaml (21.8 KB)