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

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

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.

また、ファイルの直接変更によって行われるカスタマイズは、アップグレード プロセスには含まれない点にご注意ください。このような変更は、アップグレード後のインスタンスで手動で再適用する必要があります。

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

目的

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

ソリューション 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

ソリューション 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

         



最終更新日: 2023 年 10 月 12 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.