How to enable Autocomplete Renderer for Multi-Select Custom Field in Jira

Still need help?

The Atlassian Community is here for you.

Ask the community

The information in this page relates to customizations in Jira. Consequently, Atlassian Support cannot guarantee to provide any support for the steps described on this page as customizations are not covered under Atlassian Support Offerings. Please be aware that this material is provided for your information only and that you use it at your own risk.

Also, please be aware that customizations done by directly modifying files are not included in the upgrade process. These modifications will need to be reapplied manually on the upgraded instance.

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Purpose

The purpose of this article is to show how to change the default renderer (Select List Renderer) on a Multi-Select Custom Field to use the Autocomplete Renderer without changing Jira's source code. This can be done by adding JavaScript to the custom field's description.

This document will give you more details on how to work with Custom Fields in Jira. 

Possible Solutions

Solution 1

As per JRASERVER-23013, the multi select custom field renderer can be switched to one similar to the labels picker. To enable this feature, add the dark feature: multiselect.frother.renderer

For how to enable dark feature, please refer How to manage dark features in Jira

Solution 2

  1. Go to Administration > Issues > Custom Fields;
  2. Create a Custom Field of type "Select List (multiple choices)".
  3. Click on the 'cog' icon on the right side of the newly-created custom field and click Edit;
  4. Add the below code to the Description field and click Update;

    <script type="text/javascript">
    (function($) {
        AJS.$("#customfield_<cf-id> option[value='-1']").remove(); //Removes the default value "None"
        function convertMulti(id){
            if (AJS.$('#'+id+"-textarea").length == 0){
                new AJS.MultiSelect({
                    element: $("#"+id),
                    itemAttrDisplayed: "label",
                    errorMessage: AJS.params.multiselectComponentsError
                });
            }
        }
      
        AJS.toInit(function(){ 
            convertMulti("customfield_<cf-id>");
        })
      
        JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
            AJS.$("#customfield_<cf-id> option[value='-1']").remove();
            convertMulti("customfield_<cf-id>");
        });
    })(AJS.$);
    </script>

    (info) Replace <cf-id> with the ID of the custom field you're modifying. You can get this information by running the below query on Jira's database. For example, if the ID is 10100, you'll have to change customfield_<cf-id> to customfield_10100.

    SELECT id FROM customfield WHERE cfname = '<cf-name>';

    (info) Replace <cf-name> with the name of the custom field you're modifying.

    (info) This script is verified to still work in Jira 8.20.10

         



Last modified on Oct 12, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.