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:
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.
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")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tarun, How i can handle the creation of sub-task automatically? Say for one issues user will selects only option A but for another Issue user selects Option A, B and C. In the second case it needs to create three sub-task. Is that a way i can achieve this without creating pre-defined set of Post functions rather handling it automatically based on the number of values selected?
Thanks in Advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the info. Yaah i see that as a possibility to address my scenario. On related to this question, we are trying to use multi-select dropdown with 50 values as options to choose by the selection, in this case i have to create 50 post function scenarios to address my use case correct?
Is this a only option and will have any performance impact as for creating every issue, there are 50 post functions are getting validated etc?
Is there any other option to address it? Thanks in Advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Akbar N
If the number of options is so high (50!) then don't use the post-function approach. Instead create a custom listener which should be triggered and in that listener check the number of values selected for the multi-select field and for each value create a sub-tasks using Java API in a loop.
https://developer.atlassian.com/server/jira/platform/performing-issue-operations/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Akbar N
For your use-case
"Say for one issues user will selects only option A but for another Issue user selects Option A, B and C. In the second case it needs to create three sub-task. "
You can create multiple post-functions for creation of sub-tasks and each sub-task post-fcuntion execution depends of the condition if the relevant checkbox is selected or not.
And if all the checkboxes are selected then all the post-functions will execute resulting in multiple sub-tasks being created as a result of multiple options being selected for the checkbox custom field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@[deleted] @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
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.