Script runner: creating sub-tasks based on checkbox field

Hi guys, hope you are doing great.

Here's what i'm trying to do: I have an issue parent with a checkbox custom field. After creating the issue, I would like to automatically create as many sub-tasks as options are marked on the checkbox.

For example, let's suppose the options of the checkbox field are:

  • A
  • B
  • C
  • D

While creating the parent issue I check options B and D. Right in the create transition, via post-function, I would like to automatically create two sub-task, with summary "Subtask B" and "Subtask D" for example.

 

Any clues? I'm working on JIRA 6.0

 

Thank you in advance for your help.

 

2 answers

1 accepted

1 vote
Accepted answer
Tarun Sapra Community Champion Aug 03, 2016

Hi Jose,

 

In the script-runner post-function there is a built-in postfunction to create a sub-task based on a condition.

 

Thus you can add 2 post-functions one for each sub-task and in the built-in post-function for sub-task creation you can check whats the value of the checkbox and if the value of the checkbox is what you want only then the subtask would be created.

Here's how you can check the checkbox value, this snippet can be put in the "condition" code block of the built-in script to create subtask.

cfValues['Reset Type']*.value.contains("Citrix")

https://answers.atlassian.com/questions/124728

Thank you so much! It worked. smile

 

Best.

Hello @Jose Jimenez @Tarun Sapra ,

 

Working for server. Same code is not working in cloud.  Can you provide the code for JIRA cloud?

 

Thanks,

Swathi

Hi @Tarun Sapra

 

I also tried this code on Jira cloud but it's not working. It seems this stuff is not supported in cloud. Can you please confirm if there is a script for cloud.

I am also trying to achieve this using JMWE. However, the condition does not allow me to add a condition for custom field.

 

Thanks

Suhail Wani

@Swathi Komirelli [Appfire] @Tarun Sapra

 

I sorted this out.Below is the code for Jira cloud to add the condition in the create subtask post function.

 

((List)issue.fields.customfield_<IDHere>)?.collect { it.value }?.any { it == '<OptionValueHere>' }

 

Thanks

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

885 views 3 9
Read article

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