// the project key under which the issue will get created
def projectKey = issue.fields.project.key
// the issue type for the new issue
final String issueTypeName = 'Feasibility Study'
// the summary of the new issue
final String summary = 'Feasibility Study PARENT'
def customFields = get("/rest/api/2/field")
.asObject(List)
.body
.findAll { (it as Map).custom } as List<Map>
def Duedate = customFields.find { it.name == 'Date Due' }?.id
def taskType = get('/rest/api/2/issuetype')
.asObject(List)
.body
.find { (it as Map).name == 'Feasibility Study' } as Map
def taskTypeId = taskType.id
post('/rest/api/2/issue')
.header('Content-Type', 'application/json')
.body([
fields: [
project : [
key: projectKey
],
issuetype: [
id: taskTypeId
],
summary : summary,
'Due Date' : [
Duedate : '{{now.plusBusinessDays(45)}}'
]
]
])
.asString().body
Based on the above code for the def projectKey = issue.fields.project.key Is this the correct way to set the ProjectKey to whatever the project is that we are creating an issue in? I am trying to put together a script that is robust enough so I can use this within a scripted postfunction using scriptrunner. Currently it gives me a error.