Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-76026

Label custom field JQL is not built correctly depending on the context configuration

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Low
    • None
    • 8.20.21
    • Custom fields
    • None

    Description

      Issue Summary

      When we click on a label, Jira takes us to a JQL search for that label.

      When a label custom field has multiple contexts, Jira will:

      • Restrict the search for all projects in the contexts
      • And restrict the search for all issue types in the contexts

      Apart from the issue described in https://jira.atlassian.com/browse/JRASERVER-27618, this causes issues that are only in the global context scope to not show up in the query.

      The problem happens for scopes that are global for projects and for issue types.

      This is reproducible on Data Center: yes

      Steps to Reproduce

      1. Create a label custom field
      2. Restrict it to the Story issue type
      3. Create a second context and restrict it to a project and to the Bug issue type
      4. Add a custom label to a story
      5. Click the label

      Expected Results

      A search with all occurrences of that label is opened

      Actual Results

      The search looks like this:

      project in (proj1ID,proj2ID,proj3ID) AND issuetype in ("issuetypeID1","issuetypeID2","issuetypeID3") AND AND cf[<customfield_ID>] = label-value
      

      For example:

      project in (10000,10100) AND issuetype in ("10002", "10004", "10100", "10101", "10104") AND cf[10500] = new-label
      

      Workaround

      Option 1 - not mix global context with scoped ones

      To avoid the issue, we cannot mix scoped contexts with global ones, both in projects and issue types.

      In practical terms:

      • Either limit the issue types in all contexts or in none of them;
      • Either limit the projects in all contexts or in none of them.
        You can select all projects or all issue types and it will count as limiting those parameters.

      Option 2 - announcement banner JavaScript

      Keep in mind that this kind of script might break in future Jira versions, so it's important to test it before upgrades.

      • Navigate to Administration > Issues > Custom Fields
      • Click on ... > Configure in the desired field
      • Take note of the field ID in the end of the URL
      • Navigate to Administration > System > Announcement banner
      • Add the script code below replacing 11111 in customfield_11111 with your label custom field ID
        <script type="text/javascript">
        AJS.$( document ).ajaxComplete(function( event,request, settings ) {
        	if(settings.url.indexOf('AjaxIssue') >= 0){
        		console.debug("Executing javascript for JRASERVER-27618 workaround.");
        		AJS.$('div#customfield_11111-val > div.labels-wrap.value > ul.labels > li').each(function(){
        			if ($( this ).children('a.lozenge') && $( this ).html().indexOf('jql=project') >= 0){
        				var atag = $( this ).children('a.lozenge')[0];
        				var currentHref = atag.attributes.href.value;
        				atag.attributes.href.value = currentHref.replace(/jql=project.*\+AND\+/g, "jql=");
        			}
        		});
        	}
        });
        </script>
        

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              5fb7769fcbc7 Allan Gandelman
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: