How can I use ScriptRunner to create multiple subtasks based on a post function?

Currently using JIRA CLOUD

I am building a new hire form. Once the form is created and a user clicks "Start Progress" I have it so the issue will automatically create a single subtask and assign it to a user.  

Note: The New Hire form has about 25-30 subtasks that our team will work on simultaneously from ICT to HR and Finance.

  • Create multiple subtasks where I can define subtask summary, assignee and description with a custom script.
  • Send custom email notification if a custom field matches condition
    • Example: If the department matches "Sales" then send an email to "Email Address" with preset message and include issue details(Various custom fields) within the email.

I am new to scriptrunner and groovy and would love a tutorial or guide on where I can find the fields/code needed to make this script work.

 

1 answer

This widget could not be displayed.

Hi Jesse,

You have two options here:

  1. You can create multiple 'Create Subtask' Workflow Post Functions (see http://scriptrunner-docs.connect.adaptavist.com/jiracloud/post-functions.html#_create_subtask) for the 'Start Progress' transition, and also add a Post Function for sending a notification (see http://scriptrunner-docs.connect.adaptavist.com/jiracloud/post-functions.html#_send_notification)
    When you are configuring the 'Create Subtask' post function there is an example code snippet you can use to set the assignee, and its simple to set the description using the following code:

    subtask.fields.description = "Some description"

    For the notification, you can write a code condition that checks the value of a specific custom field:

    def customFieldValue = issue.fields['customfield_10234']
    // We need to return true or false here in the condition code
    return customFieldValue == 'Sales'
  2. Alternatively, you could write a large Script Listener for an Issue Created event that does all of subtask creation manually smile

I hope that helps,

Jon

Hello Jon,

Thanks for the prompt answer I appreciate it. For option 1 I know thats possible but due to the fact that we may have 15-30 subtasks I think the manual creation is too tedious and takes too long to edit and modify. I am new to coding but I saw it was possible to setup intellij ide and connect it to JIRA so I can learn the sample groovy code? Can you point me in the right direction for that setup I tried yesterday for 30 minutes but had no clue what I was doing. For option 2 how can I learn to write the code for this, I just need some reference guides and samples!

Jesse,

 

I am looking for the same information right now. Did you ever find a good way of creating multiple sub-tasks from a single post function script?

I believe when Jon says to create a listener, he is referring to creating a global listener in the add-ons section under Scriptrunner. However, I am not well versed in Groovy and the script to actually fire the "create sub-task" event would probably take me longer to figure out than to just add 15 individual post function scripts.

Anyway, if you have any lessons learned you would like to share, I would love to hear it.

Thanks,

Jason

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

235 views 1 3
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you