Single select custom field behave like component section

Hello,

I've tried following the scripts in these questions:

https://answers.atlassian.com/questions/223068

https://answers.atlassian.com/questions/43534

I'm still not getting any results. Is there more than just entering the script into the description field and updating the custom field ID?

Thanks!

3 answers

1 accepted

Accepted Answer
0 votes

Those two questions are ancient and irrelevant to newer versions of JIRA (especially as the ability to run dodgy javascript as part of fields is being reduced because it breaks so much and so often)

Could you explain what you mean by "custom field behave like component section"?  What are you looking for? 

e.g.

  • For it to behave like a multi-select?  (You'll need to start with a multi-select cf to start on that one)
  • For it to appear somewhere else on issue view?
  • For it to be maintainable by project admins?

Currently my single select custom field has a list with all the available options, but I would like to have it appear like the component field so the user can start typing and have relevant options appear.

This works for me on a Custom Field of type Select List (multiple choices) - make sure to put this: on the Field Configuration, on the Custom Field, click edit, put the following JavaScript in the Description. Earlier versions of JIRA let me use it directly on the Custom Field description, but after a recent upgrade I had to make sure to use it on the Field Configuration.

 

<script type="text/javascript">
	AJS.$("#customfield_10698 option[value='-1']").remove();
	(function($){
		new AJS.MultiSelect({
      		element: $("#customfield_10698"), itemAttrDisplayed: "label", errorMessage: AJS.params.multiselectComponentsError
   		});
	})(AJS.$);
</script>

 

Make sure to edit the Custom FIeld ID in the two spots in the JavaScript to match your custom field id value.

 

Hope it helps.

I'm on JIRA 6.4 and this script does not work for me.

I'm also on 6.4. Did you make sure to change the occurrences of "customfield_#####" to whatever your custom field id is? Did you place this script on the "Field Configuration" description for the custom field instead of directly on the custom field's description? One issue w/ this script is that it will only work if the issue type is first selected, it won't render if you have to change the issue type in order to see this field.

The field is not issue type dependent and both field IDs are changed in the configuration description.

I found that this script worked for one field, that had just text options, but when I had things like below (it didn't work). Any ideas?

A.1.a - commercial 

A.2.a - worker

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 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...

22,486 views 2 7
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