// 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.
What is the error?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The code works for me perfectly. You are on Jira Cloud right?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Correct. I am on Jira Cloud, I guess i need to try saving it and seeing if it works on my end even ignoring the error warning.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So i ran the script and the only thing it trips up on is the duedate field. which is a system field within the issue body. I have tried many variations of date strings but it acts like scriptrunner for Jira Cloud does not accept smart values. Any ideas on what i could use to resolve this?
{"duedate":"Error parsing date string: {{now.plusBusinessDays(20)}}"}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.