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

Reporter field is not copied via the "Clone an issue, and links" listener



    • Type: Bug
    • Status: Done
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 5.3.5
    • Fix Version/s: 5.3.9
    • Component/s: Listeners
    • Labels:
    • Environment:

      ScriptRunner | 5.3.5 |

      JIRA Software | 7.7.0 |

    • Critical Points:


      If you set up a "Clone an issue, and links" script listener that specifies the Reporter field as a field to copy over, upon triggering the listener the cloned issue will be created successfully with no errors thrown. However, if you explore the cloned issue, you will see that the Reporter field was set to the currently logged in user instead of the reporter from the parent issue.

      Steps to Reproduce:

      1. In a fresh instance, add some additional users by running the below script in the script console:
        import com.atlassian.jira.bc.user.ApplicationUserBuilderImpl
        import com.atlassian.jira.bc.user.UserService
        import com.atlassian.jira.bc.user.UserService.CreateUserRequest
        import com.atlassian.jira.component.ComponentAccessor
        import com.atlassian.crowd.manager.directory.DirectoryManager
        //Define necessary managers and additional components
        def userManager = ComponentAccessor.getUserManager()
        def directoryManager = ComponentAccessor.getComponent(DirectoryManager)
        def userService = ComponentAccessor.getComponent(UserService)
        def userUtil = ComponentAccessor.getUserUtil()
        def groupManager = ComponentAccessor.getGroupManager()
        def authContext = ComponentAccessor.getJiraAuthenticationContext()
        //Define JIRA variables
        def currentUser = authContext.getLoggedInUser()
        def directoryID = directoryManager.findDirectoryByName("JIRA Internal Directory").id
        def addToGroup = groupManager.getGroup("jira-software-users")
        def numOfUsers = 5
        //Loop 5 times
        (1..numOfUsers).each {
            //Retrieve the user creation request that specifies the user's directory to be added to
            def newCreateRequest = CreateUserRequest.withUserDetails(currentUser, "deaduser$it", "deadpass$it", "deaduser$it@inactive.com", "deaduser$it").inDirectory(directoryID).sendNotification(false)
            //Get validation result for user creation (given the request)
            def createValidationResult = userService.validateCreateUser(newCreateRequest)
            //Assuming a valid result from the above statement, a new user is created
            def newAppUser = userService.createUser(createValidationResult)
            //Make user inactive
            userManager.updateUser(new ApplicationUserBuilderImpl(newAppUser).active(true).build())
            //Add user to the specified group
      1. Create two new software projects (I'll call them project X and project Y)
      2. Navigate to the Script Listener's page and create a new "Clone an issue, and links" listener with the following config:
        1. Project key: project X
        2. Events: Issue Updated Event
        3. Target Project: project Y
        4. Fields to copy: Reporter
      3. Create an issue in project X
      4. Logout and switch to one of the newly created users:
        1. username: deaduser1
        2. password: deadpass1
      5. With that user, update the issue in project X by changing one of the fields
      6. Then navigate over to project Y and examine the new issue
      7. Notice that the Reporter, instead of being the user that created the parent project, is the currently logged in user (deaduser1).




            tbatagiannis Thanos Batagiannis
            aderossett Aidan Derossett
            1 Vote for this issue
            3 Start watching this issue