Single select field to Multi Select field

Prabhu Prabhakar September 7, 2021

Hi 

we're running into the Data Center edition.

There is a Single select dropdown Customer field across all the projects of the firm.

I received a request from my Management to convert it as a multiselect field.

My opinion 

  • What I'm aware of, it's not possible (at least, safely) to try and directly convert a field from one type to another in the DB.  
    • If it can be done and is safe, I'd be happy to be wrong here. 
  • Would look like creating a new multi-select dropdown field, importing all entries to that field from the existing field, then switching all screens to use that new field.
  • Hard part is
    • This field contains more than 500 options(data).
    • If I change into Multiselect I should make sure the old data(option) should not be deleted from old/present Jira.

I'd be happy, if you suggest a way to achieve this I'd really appreciate it.

Regards,

Prabhu

2 answers

1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2021

Actually, this is one of the few times it is ok to use SQL on a Jira database.  It is a slog, you still need to be very careful, and it is usually NOT recommended to go the other way, but when some fields are of a certain type, it is possible to "convert" them to another compatible type with a bit of hackery.

The rules are:

  • The fields must contain the same type of field data.  Select lists, radio buttons, check-boxes and multi-select lists for example, all contain options, so you can convert between them.  Similarly single-user-picker and multi-user-pickers contain user accounts.  You can even convert url and text fields, but that can give you broken urls, so I'd avoid it.
  • You can only convert single to multiple without checking.  You can not convert multiple to single unless you can be 100% sure your multi-option field contains only 0 or 1 options for every issue in the system

To do it

  1. Take Jira offline
  2. Take a full backup of the database just in case (ideally, prove you can restore it too)
  3. Look at the "customfield" table.  Find your custom field and change the type of it - this table points to a class, so you'll need to replace the full class name with the new one.  Do not change anything else, including the searcher, even though the searcher might be junk for the new field type
  4. Restart Jira
  5. Go and edit the field you have changed from admin -> custom fields.  Check the name, the type, and if they are looking ok, then edit the searcher, selecting a new one (even if the old one was valid, change it, save it, then, if necessary, go back in and change it again to the one you want to use)
  6. Kick off a full locking re-index for the entire system.
  7. Ta-da - you have now converted a field from one type to another.
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2021

cool! you should do a video KB on this. ;-)

Prabhu Prabhakar September 8, 2021

Hi @Nic Brough -Adaptavist- 

I'll try this and thanks for your suggestions! 

1 vote
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2021

You can’t convert a field from single select to multi select. At least this is my understanding and my experience in cloud. What you could consider doing is create a new multi select with all of the same options. Then you could use CSV to import the values from existing issues. Disclaimer – I have not done this myself but I understand from others that it will work and my understanding of import would seem to back that up. Certainly worth a try a test project.

Prabhu Prabhakar September 8, 2021

Hi @Jack Brickey Thanks for your suggestion!

Guz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 13, 2021

That doesn't seem to work in Jira (Server/DC). Just tested here. 
It happens that when you export the CSV, you're actually populating the table with the current value presented in the field at that moment you're exporting the issue to the CSV. So, when you're importing back to the system, the only value brought, is the one chosen for that field, not all the values available for picking. 
So in the end, it's not possible to convert in Server/DC solution.
Not sure about Cloud.

Guz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 13, 2021

Still, it seems that Behaviours from ScriptRunner allow you to do it. You might want to look at it. 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 13, 2021

Actually, there's a couple of things here.

If you use CSV to import issue values into a select list (of any type - single, multi, radio, checkbox etc), then it can create the options you need to add to it as you go.

I've used this a few times in the past to populate large numbers of options into fields by creating dummy projects, importing one issue per option I want to add, and then killing the project off later.

And, I'm afraid Behaviours won't help you here.  Behaviours works on the front-end, and although you could get it to convert the use of a single-select so it looks like a multi-select, it will fail when saving values because the single-select option won't be there for multiple values.

You could use Scriptrunner console to copy the options over into the new field though, and copy the issue values into the field as well.

Guz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 14, 2021

Another detail regarding the import from a CSV is that the only way Jira allows a user to import a CSV mapping a Single-select CF to a Multi-select CF type, is via the External System Import, in the Jira Admin > System. So that's not a task that an ordinary user would be able to do.

So, in the end, the best approach for this scenario would be the change in the database. 

But one thing it didn't get clear for me @Nic Brough -Adaptavist-, and I'm sorry for my ignorance here, is how did you manage to perform the export of the values available on the options of the field. As a matter of learning and morbid curiosity,, would you mind sharing the steps?

Thanks in advance!

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 14, 2021

Yes, the population of the options list is definitely an admin thing, done with external import (it would be an admin action anyway, you need to be an admin to edit the options in select lists)

I would run away screaming from "do it in the database".  Unless you know exactly what you are doing, you are going to break your Jira.  You also need proven backups, significant downtime, a proper-roll back plan and decent testing before you even think of this.

Getting the list of options to go into a field isn't hard, but is a bit of fiddling with data.  Sometimes, the list is given to us, but that's for new fields, not converting existing ones.  With a conversion, I've seen people simply scrape it from the html of the create issue screen, scrape it from the admin screen for the list of option in the custom field options, or use a REST call to fetch it.  In all of those, you have to do a bit of work to convert html, tables or json into a simple CSV list, but it's not that hard.

Suggest an answer

Log in or Sign up to answer