Disable issue type javascript

Yannick Le Goualher June 20, 2015

Hi,

I've  updated my JIRA instance in from 6.3.15 to 6.4.6.

I used a script to disable some issue type with javascript for group of people on the issue creation screen, but my script doesn't work anymore and I don't understand why.

 

jQuery(document).ready(function($) 
        {    
            JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e,context) {   
                $("#issuetype option").each(function()  {  
                    if( $(this).text().trim() == "Type1" || $(this).text().trim() == "Type2")
                        {    
                         $(this).remove();        
                        }                    
                });    
            });
        });
 }

 

It seems that this script is not executed.

It worked perfectly in 6.3.15.

Has anybody an idea?

 

Thank you

6 answers

1 vote
Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 24, 2015

We just recently upgraded to 6.4 and I had to figure it out as well. It seems like the select has been replaced with a single-select that pulls the information from another source, so this is what I did to remove the issue types. It's not so elegant, but at least it works OK. It should actually work on 6.3 as well.

jQuery(document).ready(function() {
  var removeIssueType = function() {
    jQuery("a[title='type1']").parent().hide();
    jQuery("a[title='type2']").parent().hide();
  }
  var findIssueType = function() {
    jQuery("span.drop-menu").click(removeIssueType);
    jQuery("#issuetype-field").keyup(removeIssueType);
    jQuery("#issuetype-field").click(function() {
      setTimeout(removeIssueType, 1);
    });
    jQuery("#project").change(function() {
      setTimeout(findIssueType, 1000);
    });
  }
  if (AJS.params.loggedInUser !== "allowed.user") {
    JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e,context) {
      findIssueType();
    });
    setTimeout(findIssueType, 500);
  }
});

That should be enough to get you started for any customizations.  Just replace "type1" and "type2" with the types you want to remove.

Suresh March 31, 2016

we have JIRA 7.0.2, but script is not working correctly, I am doing any mistake,Please let me know,

Thank you for the help.

jQuery(document).ready(function() {
  var removeIssueType = function() {
    jQuery("a[title='Core Patch Request']").parent().hide();
    jQuery("a[title='Customization Patch Request']").parent().hide();
  }
  var findIssueType = function() {
    jQuery("span.drop-menu").click(removeIssueType);
    jQuery("#issuetype-field").keyup(removeIssueType);
    jQuery("#issuetype-field").click(function() {
      setTimeout(removeIssueType, 1);
    });
    jQuery("#project").change(function() {
      setTimeout(findIssueType, 1000);
    });
  }
      JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e,context) {
      findIssueType();
    });
    setTimeout(findIssueType, 500);
});
Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 1, 2016

Yeah, sorry, I guess I never updated it since they removed the title element sometime during the 6.4 development process.  This version should work (just tested it with the latest version of JIRA Cloud):

<script>
jQuery(document).ready(function() {
  var removeIssueType = function() {
    jQuery(".aui-list-item-link").filter(function(){ 
	  return jQuery(this).text() === "Core Patch Request" || jQuery(this).text() === "Customization Patch Request" 
	}).parent().hide();
  }
  var findIssueType = function() {
    jQuery("span.drop-menu").click(removeIssueType);
    jQuery("#issuetype-field").keyup(removeIssueType);
    jQuery("#issuetype-field").click(function() {
      setTimeout(removeIssueType, 1);
    });
    jQuery("#project").change(function() {
      setTimeout(findIssueType, 1000);
    });
  }
  JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e,context) {
    findIssueType();
  });
  setTimeout(findIssueType, 500);
});
</script>
Like Maggie Gu likes this
Vladimir Sid January 24, 2018

Hey, @Stephen Deutsch is there a possibility to use project category instead of project name ? Like there are many projects which needs to hide few issuetypes and needs to be hidden based on category. Thank you so much.

Rajesh Ramankutty November 19, 2018

Hi Team,

kindly tell me where we need to use this code to hide the issue type in jira?????

0 votes
Peyyala Madhusudhana Rao August 9, 2017

I am facing the same problem. Can i have sample code snippet please.

0 votes
Yannick Le Goualher June 26, 2015

Hi it works fine, thank you very much for your help!!

0 votes
Yannick Le Goualher June 25, 2015

Hi,

thank you for your answers. I'll test it tomorrow and give you my feed back.

 

0 votes
Christophe Promé June 23, 2015

This is because Atlassian switched to AUI Select 2 component :

<div class="aui-list" id="issuetype-suggestions" tabindex="-1" style="display: block;">
    <div class="aui-list-scroll" tabindex="-1">
        <ul class="aui-last">
            <li class="aui-list-item aui-list-item-li-bug active"><a class="aui-list-item-link aui-iconised-link" href="#" title="Bug"><img class="icon" alt="" src="...">Bug</a></li>
            <li class="aui-list-item aui-list-item-li-epic"><a class="aui-list-item-link aui-iconised-link" href="#" title="Epic"><img class="icon" alt="" src="...">Epic</a></li>
            <li class="aui-list-item aui-list-item-li-technical-task"><a class="aui-list-item-link aui-iconised-link" href="#" title="Technical Task"><img class="icon" alt="" src="...">Technical Task</a></li>
        </ul>
    </div>
</div>

You have to adapt your code and remove the aui-list-item element corresponding to the issue type you want to remove, they all have a specific class: 

aui-list-item-li-bug
aui-list-item-li-epi

etc ..

Beware though, this element is appended to the DOM when the user focus the issue type select.

0 votes
Yannick Le Goualher June 20, 2015

It seems that the <select id='issuetype' has disapeared...

I don't know how to adapt my script. I only find div

Suggest an answer

Log in or Sign up to answer