I am using JIRA cloud and installed ScriptRunner from the Atlassian Marketplace.
I was wondering how I can use ScriptRunner to pre-populate the Description field when creating a new ticket of a certain project / issue type?
In Script Listeners, I can only select "Issue created" for the "on these events", but I assume that is already too late and only executed when the issue was submitted through the "Create" button?
What I would need is took hook into an even such as "onCreate"? How do I achieve this?
And this is how my script would look like:
def projectKey = project.key as String
logger.info("Creating new issue in ${projectKey}")
logger.info("Checking for issue type Initiative")
def issueTypesReq = get("/rest/api/2/issuetype").asObject(List)
assert issueTypesReq.status == 200
def taskType = issueTypesReq.body.find { it.name == "MyCustomIssueType" }
assert taskType // Must have an issue type named Initiative
logger.info("Updating Description field")
def result = put("/rest/api/2/issue/${issue.key}")
.header('Content-Type', 'application/json')
.body([
fields: [
description: "h2. Description:\nBlabla\n\n"
]
])
.asString()
Can anybody give me a hint where / how to place this?