is it possible to hide some specified affected version when creating an issue?

I use JIRA v6.1.3.

My project has some released version. eg. (V1.0 , V1.0.1 , V1.0.2 , V1.0.3, V1.1 , V1.1.1 , V1.1.2 )

I need to hide V1.0 to V1.1.1 when people create an issue.

And why I don't choose to archive V1.0 to V1.1.1  versions,is that archived versions related issues can not be searched in issue navigator.

I tried to use AJS in Behaviours Plugin

FormField versions = getFieldById("versions")
FormField desc = getFieldById("description")
if(getActionName()!=null && getActionName()=="Create Issue"){
 desc.setFormValue("create screen:"+getActionName()+versions.getValue())
 versions.setHelpText("<script type=\"text/javascript\">\
  AJS.\$(\"#versions optgroup\").each(function() { \
 AJS.\$(\"#environment\").val(\"22\"+AJS.\$(this).attr('label'));\
 if (AJS.\$(this).attr('label')==\"Released Versions\"){ \
AJS.\$(\"#environment\").val(\"333\");\
AJS.\$(this).find('option').each(function() {AJS.\$(this).hide();});\
}\
});\
 </script>")
}

but 

AJS.\$(this).find('option').each(function() {AJS.\$(this).hide();});\

this code didn't work

1 answer

I use below code as temporary resolution.

input js code into affect versions filed's description.

<script type="text/javascript">
// on create issue screen ,remove released versions.
jQuery(document).ready(function($) {
	var createScreen=document.getElementById('create-issue-submit');
	removeOption();
	JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
	removeOption();
	});
	function removeOption(){
		if(createScreen !=null && createScreen.value == "Create"){
			$("#versions optgroup").each(function() {
				if ($(this).attr('label')=="Released Versions"){
					$(this).find('option').each(function(){$(this).remove();});
			  }
			});
		}
	}
});
</script>

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted yesterday in Confluence

Calling all marketing teams who use Confluence - we want to hear from you!

Hi Community! me again 🙂 If you’re a marketing team using Confluence, we want to hear your story! How did you start using Confluence? What are your use cases? What have been some of the benefits?...

84 views 2 3
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