I needed to create a country field in Freshdesk in the Contact and Account forms. But I found (disappointingly) the lack of a built-in field that had al the countries already.
Also, while there is a REST API to create ticket fields, there is not one for Contacts or Companies field.
Since there are 241 countries I did not want to type or copy/paste that many entries into 2 different forms. So I used Applescript to automate this as follows:
- Open Apple scripteditor and enter following command: activate application "Google Chrome"
tell application "System Events" to keystroke "Brazil" & (keystroke (ASCII character 9))-
Note: I used Excel to build this list. Here is my XLS. Just pasted the contents into script editor. (if for some reason this is not there in future just google a list of countries)
-
- Create a new dropdown field
- Click “Add item” as many times as needed (in my case 241 times)
- Create a couple more than you need in case you mis-count
- you can click thru this pretty fast so you can count up to 250 pretty quickly
-
Scroll back up to the top of the Dropdown items list and select 1st item
-
Open the Script Editor with your code ready to go
-
Press Run. Be Patient and let it run to completion w/o touching the mouse or keyboard (since this depends upon Chrome having focus)
Now delete the empty items at the end of the list. Also you may have 1 blank item at top of the list.
Now save.
Note: You can re-create the list if you want to add entries or change the order. Because tab thankfully selects the contents of the next field, the script will overwrite previous entries.