Pre-selecting MultiSelect with default value using Behaviours plugin

Hello.

We have a multi select list in our transition screen where it is pre-selected according to the selected values in the same select list in the parent Jira.

In Behaviour plugin, we pre-select the select list by using setFormValue function. It works but what we would like to do is displaying and converting the multi select list to an auto complete multi picker.

We use the following code to convert the select list into a auto complete multi picker by pasting the lines in the description field.

<script type="text/javascript">
(function($) {
 // "customfield_11315" 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_11315 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_11315");
    })
    JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
        AJS.$("#customfield_11315 option[value='-1']").remove();
        convertMulti("customfield_11315");
    });
})(AJS.$);
</script>

The problem here is that the auto complete multi picker doesn't display the pre-selected by the Behaviours plugin (setFormValue) in its text area. The pre-selected values aren't available in auto comlete multi picker's available (unselected) dropdown list either.. so i assume the values are actually selected but just are not displayed correctly in the multi picker's text area.

Has anyone else come across with this issue? I wonder if I could get the pre-selected option values correctly displayed in the auto complete multi picker's text area by tweaking the javascript above?

Thank you in advance!

2 answers

This widget could not be displayed.

I suppose I must rephrase my question..

Is it possible to pre-select auto complete multi select picker and pre-populate the selected options?

This widget could not be displayed.

Worked it out by manually setting "selected" property to the option values via jQuery script before converting the select list to auto complete multi select picker :)

it will be great if you share your solution here.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

39 views 0 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you