Uploaded image for project: 'SR for Jira - Development'
  1. SR for Jira - Development
  2. SRJIRA-403

Script field content is shown or not shown by chance

    Details

    • Type: Bug
    • Status: Done
    • Priority: Major
    • Resolution: Obsolete
    • Affects Version/s: 2.1.15, 2.1.16
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Environment:

      JIRA 6.2

    • Critical Points:
      0

      Description

      We have a script field that calculates a path in a structure defined by links of a specified type:

      import com.atlassian.jira.component.ComponentAccessor
      import com.atlassian.jira.issue.link.IssueLinkType
      import com.atlassian.jira.issue.link.IssueLink
      import com.atlassian.jira.issue.Issue
      import org.apache.commons.lang.StringUtils
      
      def issueLinkTypeId1 = 10263L   // Link type id 'PSP Work Package'
      def issueLinkTypeId2 = 10262L   // Link type id 'PSP Structure'
      
      def jiraAuthenticationContext = ComponentAccessor.jiraAuthenticationContext
      def linkCollection
      def parent = issue.parent
      
      if(parent) {
      	linkCollection = ComponentAccessor.issueLinkManager.getLinkCollection(parent, jiraAuthenticationContext.getLoggedInUser())
      } else {
      	linkCollection = ComponentAccessor.issueLinkManager.getLinkCollection(issue, jiraAuthenticationContext.getLoggedInUser())
      }
      
      def title = new StringBuilder("")
      def linkType1
      def linkType2
      def outwardIssues
      def processedIssues = new ArrayList()
      
      while (issue) {    	
      	for(IssueLinkType t : linkCollection.linkTypes) {
      	    if(t.id == issueLinkTypeId1) {
      	    	linkType1 = t 
      	    }
      	    if(t.id == issueLinkTypeId2) {
      	    	linkType2 = t
      	    }
      	}
          
          if(linkType1) {
          	outwardIssues = linkCollection.getOutwardIssues(linkType1.name)
          }
      	if(!outwardIssues && linkType2) {
      		outwardIssues = linkCollection.getOutwardIssues(linkType2.name)
          }
      	    
          if(outwardIssues) {
              
              def outwardIssue = outwardIssues.get(0)
           	
           	if(outwardIssue) {
           		if(!processedIssues.contains(outwardIssue.key)) {
      				issue = outwardIssue
      				title.insert(0, issue.summary)
      				title.insert(issue.summary.length(), "#")
      				linkCollection = ComponentAccessor.issueLinkManager.getLinkCollection(issue, jiraAuthenticationContext.getLoggedInUser())
      				processedIssues.add(outwardIssue.key)
      			}
           		else {
           			title = new StringBuilder("")
           			title.append("CYCLE ERROR")
           			issue = null
           		}
           	}
          } else {
          	issue = null
      	}
      	
      	outwardIssues = null
      }
          	
      return StringUtils.removeEnd(title.toString(), "#")
      

      The script follows the links of the specified type and collects all titles of the issues by following the links upwards. Most times the script works and shows the link path. By chance the field is completely empty as shown in the screenshots.

      We see this behaviour also in our export jobs where long lists of issues are exported (with their work logs). These exports should contain the script field too, but in some of the entries the script field is empty.

      Is this a bug in our script or are there limitations for script runner running in batch operations or in screens showing long lists with the script field?

      PS: I forgot to mention that the script field is named "PSP Work Package". You can see it on the screenshots after labels.

        Attachments

          Activity

            People

            Assignee:
            jechlin Jamie Echlin
            Reporter:
            christian.heissing@codecentric.de Christian Heißing
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: