This tutorial will take you through the steps needed to create a new issue in another project and transfer the information needed, once your original request is resolved.

Use Cases:

  1. When a user raises a bug report, if it is verified, you want to automatically add it to your backlog in your development project.

  2. When a request for an item is approved by your manager, you want it to be placed in another project so that the appropriate team can can acquire it.

  3. When a person has been successfully hired, you want to auto raise a ticket to IT so that their login and basic IT is provided for them.

  4. When an incident has been fixed and you need to file a Root Cause Analysis(RCA) ticket in another project.

Steps:

We need to setup a "Clones an issue, and links" postfunction in the transition that closes your ticket.

1. Set up the condition:

a): the request type is the one pertinent to us. In this case "Bug Report"

b): the transition to closed with a resolution that implies that you are going to do something with that ticket. In this case "Bug Reproduced"

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

@WithPlugin("com.atlassian.servicedesk")
def requestTypeService = ComponentAccessor.getOSGiComponentInstanceOfType(RequestTypeService)

if(issue.issueType.name=="Incident") {

    def sourceIssueRequestTypeQuery = requestTypeService.newQueryBuilder().issue(issue.id).build()
    def requestTypeEither = requestTypeService.getRequestTypes(currentUser, sourceIssueRequestTypeQuery)

    if (requestTypeEither.isLeft()) {
        log.warn "${requestTypeEither.left().get()}"
        return false
    }

    def requestType = requestTypeEither.right.results[0]

    if (requestType.name=="Bug Report" && issue.resolution.name == "Bug Reproduced") {
        return true
    }
}

return false

2. Setup the other fields.

Setup the target project, target issue type and fields to copy.

postfunction copy
This is example, you could choose to copy the whole issue if you wish

For how-to questions please ask on Atlassian Answers where there is a very active community. Adaptavist staff are also likely to respond there.

Ask a question about ScriptRunner for JIRA, for for Bitbucket Server, or for Confluence.