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

The getContextIssueId() method returns value from a previously selected issue

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 5.5.7
    • Fix Version/s: None
    • Component/s: Behaviours
    • Labels:
      None
    • Critical Points:
      1.8

      Description

      The method getContextIssueId() should get the ID of the issue that was on the screen when the item was clicked but is getting the ID of the first issue select even after selecting other issues. 
      This issue is affecting the version 5.5.7 because it worked fine in version 5.5.6.

      Steps to Reproduce

      • Create a "Show a web panel" Script Fragment and use the script below in the "Provider class/script" field.
        writer.write('<a href="/secure/CreateIssue!default.jspa#" class="toolbar-trigger sr-create-bound-issue" id="BETEST-panel-attach-issue">')
        writer.write('<span class="trigger-label">Attach task</span>')
        writer.write('</a>'

        Here you can see the rest of the configuration.

      • Create a behaviour and use the script below in the "Initialiser" field.
        import com.atlassian.jira.component.ComponentAccessor
        
        def issueManager = ComponentAccessor.getIssueManager()
        //log.warn("issueManager: " + issueManager)
        
        def behaviourContextId = getBehaviourContextId()
        //log.warn("behaviourContextId: " + behaviourContextId)
        
        if (behaviourContextId == "BETEST-panel-attach-issue") {
        
            log.warn("getContextIssueId(): " + getContextIssueId())
        
            def contextIssue = issueManager.getIssueObject(getContextIssueId())
            log.warn("contextIssue: " + contextIssue)
        
            def issueKey = contextIssue.getKey()
        //    log.warn("issueKey: " + issueKey)
        
            def summaryField = getFieldById("summary")
        //    log.warn("summaryField: " + summaryField)
        
            def newSummaryValue = "original issue: " + issueKey
        //    log.warn("newSummaryValue: " + newSummaryValue)
        
            summaryField.setFormValue(newSummaryValue)
        }
        
      • Go to one issue and click on the link of the Web Panel, as the first time it will work as expected
      • Go to another issue and click again on the link of the Web Panel, it will show the issue key from the last issue

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              jmarques Jose Marques
              Votes:
              4 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: