Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

create mulitple subtasks from multiselect checkbox field

My issue create screen has a multi-select checkbox custom field. I would like a scriptrunner post-function that will:

a) create a sub-task for each option selected

b) use the name of the selected checkbox in the sub-task summary



My custom field is called: "colors"

The following options exist:

  • "blue"
  • "green" -> checked
  • "red" -> checked


Desired outcome from post-function: Create two sub-tasks with summary as follows:

1) "Subtask - green"

2) "Subtask - red"

I am using jira server 7.x and latest scriptrunner plugin.

1 answer

1 accepted

0 votes
Answer accepted

I think you should try to write a script yourself first. You can find info on how to create subtasks using scriptrunner here:

I created the following script which works.

However I have not figured out how to set a checkbox in the newly created sub-task as indicated in the code comment.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.customfields.manager.OptionsManager

import com.atlassian.jira.user.ApplicationUser

import org.apache.log4j.Logger
import org.apache.log4j.Level

def log = Logger.getLogger("com.acme.CreateSubtask")

def constantManager = ComponentAccessor.getConstantsManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def issueManager = ComponentAccessor.getIssueManager()
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
Issue parentIssue = issue

def customFieldManager = ComponentAccessor.customFieldManager
def cf = customFieldManager.getCustomFieldObject("customfield_10107")
def summariesList = (issue.getCustomFieldValue(cf) as Collection<Option>)*.value

summariesList.each {
if (!issue.getSubTaskObjects()*.summary.contains(it)) {
MutableIssue newSubTask = issueFactory.getIssue()
newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{it.getName() == "Sub-task"}.id)

// I want to set a checkbox field in newly created sub task next

def optionsManager = ComponentAccessor.getComponent(OptionsManager)
def cFM = ComponentAccessor.getCustomFieldManager()
def cff = customFieldManager.getCustomFieldObject("customfield_10107")
def fieldConfig = cff.getRelevantConfig(issue)
def option = optionsManager.getOptions(fieldConfig).getOptionForValue("${it.toString()}", null)
newSubTask.setCustomFieldValue(cf, [option])

def newIssueParams = ["issue" : newSubTask] as Map<String,Object>
issueManager.createIssueObject(user, newIssueParams)
subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user) "Issue with summary ${newSubTask.summary} created"

Kindly read my article here

You use the frist method in my article. You should get options for the field like this

def List<Option> getOptions(Issue issue, CustomField customField, List<String> optionList) {
    def config = customField.getRelevantConfig(issue)
    def options = ComponentAccessor.getOptionsManager().getOptions(config)
    def optionsToSelect = options.findAll { it.value in optionList }

and set the value like this

issue.setCustomFieldValue(checkbox_field, getOptions(issue, checkbox_field, ["option 1", "option 2"])) 

That worked. Thanks for your help.

Suggest an answer

Log in or Sign up to answer
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

78 views 0 4
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