Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

creating a issue based on a postfunction in script runner Edited

// 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")
.findAll { (it as Map).custom } as List<Map>

def Duedate = customFields.find { == 'Date Due' }?.id

def taskType = get('/rest/api/2/issuetype')
.find { (it as Map).name == 'Feasibility Study' } as Map

def taskTypeId =

.header('Content-Type', 'application/json')
fields: [
project : [
key: projectKey
issuetype: [
id: taskTypeId
summary : summary,
'Due Date' : [
Duedate : '{{now.plusBusinessDays(45)}}'






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.

1 answer

0 votes

What is the error?

the error is " The variable [issue] is undeclared.

The code works for me perfectly. You are on Jira Cloud right?

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.

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)}}"}}

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

Announcing Mindville Insight is now part of Jira Service Management!

Hello Community! We’re excited to announce that Mindville Insight’s asset and configuration management capabilities will now be integrated into Jira Service Management Premium and Enterprise plan...

600 views 9 14
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you