How to more easily create dropdown with many items (e.g. country)

  • 19 February 2021
  • 10 replies
  • 1021 views

Userlevel 3
Badge +6

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:

  1. Open Apple scripteditor and enter following command: activate application "Google Chrome"
    tell application "System Events" to keystroke "Brazil" & (keystroke (ASCII character 9))
    1. 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)

  2. Create a new dropdown field
  3. Click “Add item” as many times as needed (in my case 241 times)
    1. Create a couple more than you need in case you mis-count
    2. you can click thru this pretty fast so you can count up to 250 pretty quickly
  4. Scroll back up to the top of the Dropdown items list and select 1st item

  5. Open the Script Editor with your code ready to go

  6. 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.


10 replies

Userlevel 5
Badge +9

Hello Steve,

 

Thank you for sharing your insights on bulk-adding dropdown customer field options in Freshdesk.

 

Quoting your example, we have provided the ability to add up countries as a custom field for our customers based on their business requirements. Also, at the moment, bulk addition of dropdown field options is possible in the Ticket fields section, however, please be assured that we are working on enhancing the Customer fields section as well to make it easy for configuring fields accordingly. 

 

Feel free to drop an email to support@freshdesk.com for any further queries in the future. Happy to assist you, anytime.

 

Cheers,

When you create a drop-down list, you can only make one selection. If you select another item, the first one is replaced with the new selection.

He wanted to make multiple selections from the same drop-down in such a way that the selections get added to the already present value in the cell.
How to Tell if Your Computer Mouse Is Dying?

Userlevel 5
Badge +9

Hello @tech lounge,

 

For the requirement of having dropdown fields with multiple choice selection ability, at the moment, we do not support the same. Considering this to be a valid usecase, we already have this in our list of feature requests and we would make sure to make some noise when this is made available! :)

As a workaround, for now, you can make use of the checkbox ticket field to suffice multiple selections. 

 

Cheers,

Userlevel 3
Badge +6

Its been over a year and still no ability to bulk add entries to FD Contacts or Companies form entries.  

@freshwork team, this seems like an important capability.  For myself I’d be fine with a REST API but I think other users would want the bulk add and edit feature as was suggested was “on the way” by Hemmanth above.

Userlevel 2
Badge +4

noice

Userlevel 2
Badge +4

liked my comment noice

Today I will share you a knowledge about aaliyaan Chaudhary. Aaliyaan Chaudhary is a seasoned freelancer known for his Fiverr top-rated seller. More visit: 

Userlevel 4
Badge +12

Hello @stevemc! Thanks for sharing the workaround to add multiple choices to dropdown fields in Contact/Company modules. I also wanted to share a different approach that involves executing a script in the browser console.

 

Steps to add dropdown choices using the console:

Step 1: Format the dropdown choices using Google Sheets/Excel

Add the choices to a column in the Google sheet. Add the formula (=CONCATENATE(CHAR(34),A1,CHAR(34),",") to get the choices in the desired format. The CONCATENATE function adds double quotes CHAR (34) on either side of the cell value and a comma at the end. 

 

Step 2: Add the formatted choices to this script.
 

Choices = [ //Add choices here
]
                             
for(i=0;i<Choices.length-1;i++) {    
jQuery("#addchoice").click();
}
jQuery(".dropchoice input").each(function(i){
      jQuery(this).val(Choices[i]);
})

Step 3: Go to Admin > Customer Fields and click open the dropdown field. Open the browser console and execute the script.

 

 

Sample script:
 

Choices = [
"USA",
"Canada",
"Mexico",
"Antigua and Barbuda",
"Argentina",
"Bahamas",
"Brazil",
"Cayman Islands",
]
                             

for(i=0;i<Choices.length-1;i++) {    
jQuery("#addchoice").click();
}
jQuery(".dropchoice input").each(function(i){
      jQuery(this).val(Choices[i]);
})

 

Please try this out and let me know if it helps!

 

Cheers!

Badge

@aravind.sundararajan This is so close to what I wanted to do - instead of the array “choices” I want to derive the choices from a JSON payload which is returned by an API call. I just can’t figure out the syntax to do it; any light you can shed will be highly appreciated - you’ve done 99% of the heavy lifting using the array parser loop and all the other mechanics to make a dropdown populate! Thank you!

"Thanks to Pestclean for their exceptional pest control services! They swiftly handled the pest issue at my home, providing a clean and pest-free environment    <a href="https://pestclean.ae/>Pestclean</a>

Reply