How to enable Autocomplete Renderer for Multi-Select Custom Field in Jira
このページの情報は、Jira のカスタマイズに関連しています。アトラシアン サポートの提供内容にカスタマイズは含まれていないため、アトラシアン サポートでは、このページで記載されている手順に対するサポートを保証できません。この資料は情報提供のみを目的としており、記載内容は自己責任の下で行っていただく必要があります。
また、ファイルの直接変更によって行われるカスタマイズは、アップグレード プロセスには含まれない点にご注意ください。このような変更は、アップグレード後のインスタンスで手動で再適用する必要があります。
プラットフォームについて: サーバーと Data Center のみ。この記事は、サーバーおよび Data Center プラットフォームのアトラシアン製品にのみ適用されます。
目的
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:
- Go to Administration > Issues > Custom Fields;
- Create a Custom Field of type "Select List (multiple choices)".
- Click on the 'cog' icon on the right side of the newly-created custom field and click Edit;
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>
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 changecustomfield_<cf-id>
tocustomfield_10100.
SELECT id FROM customfield WHERE cfname = '<cf-name>';
Replace
<cf-name>
with the name of the custom field you're modifying.This script is verified to still work in Jira 8.20.10
Solution 2:
This feature has been requested in Suggestion: JRASERVER-23013
As a work around, the multi select custom field renderer can be changed by enabling dark feature "multiselect.frother.renderer". For how to enable dark feature, please refer How to manage dark features in Jira.