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

Error when clicking on a label (custom field with context of two projects)

    XMLWordPrintable

Details

    Description

      Steps to reproduce the problem:

      1. Create two projects using common screen/screen schemes. You can use the default screen for all issue types and default screen scheme for both projects.
      2. Add a new custom field with any name. You can use "label" for example.
      3. In the configuration section for newly created field, make it available to any issue type and restrict the scope of this field to just the two newly created projects.
      4. In the screen association for this field, select default screen.
      5. Add a user to first project with create issue rights. This user must not have any rights over second project.
      6. Using this user, create a new issue in first project and enter some value for the "label" field.
      7. When the issue is created and displayed on screen, click on the newly created label.
      8. At this point, the error screen is displayed. It shows the query that is trying to search for this custom field in both projects. Something like:
        project in ("10000", "10001") AND cf[10000] = xxx
        

      With error on top: The value '10001' does not exist for the field 'project'.

      If you sign in with a user who has permissions on both projects, no error is displayed and the query returns the results.

      Edit
      Essentially a jql that points towards a project/issue or anything that the user does not have access to, this error will show up. Instead, the query should be ran despite the user not having this access, and the results should be filtered according to the users permissions afterwards. Customers can work around this issue by making the specific field a global field, and hide it from the screens in the projects it isn't relevant to.

      Workaround

      If you need to keep the current custom field context configuration, then you can implement a JavaScript based workaround to modify the target URL after the page is loaded to the user.
      You can use the Announcement Banner to add the custom JavaScript code. You may use a different path based on how you administer Jira, such as through ScriptRunner.

      The script is the following – note you need to modify customfield_11111 based on your custom field:

      <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
              isiagian Immanuel Siagian (Inactive)
              Votes:
              14 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated: