To get a multi-select custom field to behave like system multi-select fields with type-ahead and lozenges I added this JavaSecript to the Description of the field:
<script type="text/javascript">
(function($) {
// "customfield_11301" is the number of the custom
// multiselect field you want to change as e.g.
// seen at the end of the "configure" page url of
// the field you want to change this way
AJS.$("#customfield_11301 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_11301"); }
)
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context)
{ AJS.$("#customfield_11301 option[value='-1']").remove(); convertMulti("customfield_11301"); }
);
})(AJS.$);
</script>
This worked for years, but stopped working after upgrading to Data Centre version 8.9.1. The JavaScript was just shown in text under the field in the Create Issue screen.
I found I could get the desired behaviour for multi-select fields by installing a plugin, select2 from https://marketplace.atlassian.com/apps/1220214/select2?hosting=datacenter&tab=overview
The problem remaining is that after deleting the JavaScript from the description, it is still being displayed under the field in the Create Issue screen. I tried re-indexing, but the JavaScript is still displayed although it is no longer in the Description field.
Oddly, field descriptions may be held in two places.
I'd guess you removed the data from Admin -> Issues -> Custom fields -> That field ->
The script might also be lurking in the project data. Go to the project where the issue is still showing it on create and go to project admin -> field configuration scheme -> field configuration for that issue type -> find your field and check the field description there.
You're a champion, Nic. That was the problem.
I'll buy you a beer the next time you're in Sydney :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's an obscure one! Glad to help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Nic Brough We are having the simillar issue post upgrade multiselect value is not able to disable the available value ex.
AJS.$("#customfield_13704 option[value='-1']").remove(); which used to work , now no longer works. Any thoughts on how this can be resolved?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian are gradually removing the ability to inject javascript through field descriptions, so I'd recommend you look at a different way to do it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.