Hi guys,
i'm trying to auto-create subtasks for issues on certain transitions that meet requirements.
but i don't want them to be recreated if this process has to be repeated. I am using scriptrunner built in script for auto-creating subtask on transition.
I want to create a condition for avoiding the creation for the post function feature 'create subtask' if a subtask with the same issue type already exists.
any help is appreciated
Dan
so i kind of took a mix of everything.
you can do exactly what i needed using the script that Jonny provided. if you take
!issue.subTaskObjects.any{
}
So, Vasiliy is almost there. What you could do is create a condition on your post function to determine if any of the subtask objects have the issue type you're concerned about. You'll have to hard-code it, since, as Thanos noted, the value of the drop-down field won't be available to the condition at runtime (at least, not without a lot of hacking).
Something like
!issue.subTaskObjects.any{ it.issueType.name == "The Target Issue Type I want to avoid" }
If you're leaving the target issue type blank, the function will just default to the same type as the parent issue (assuming that's a valid sub-task type), so you could do something like:
!issue.subTaskObjects.any{ it.issueType == issue.issueType }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
do i have to also code in something like. get list of sub tasks to search for the issue type?
because in a way you don't need to know the value of the target issue type. if you give it the condition of if a sub task with this issue type exists stop process kinda thing. you don't need to tell it to be the same one do you?
or can i simply state
!issue.subTaskObjects.any{
} and then any other conditions i need?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
can things only on the dropdown be done on the create subtask post function then?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
any assistance is always helpful so if you have anything you think will be good please send it my way
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is code to loop all subtasks for issue. It stops when issue with specidied issue type name is found
import com.atlassian.jira.issue.Issue for(Issue subTask: issue.getSubTaskObjects()){ if(subTask.getStatusObject().getName().equals("issueTypeName")) return; }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
then from here do i just have to write the code on how to create the subtask etc?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniel
I am afraid that this is not possible using the built in create subtasks post function, because in the condition field you cannot know the value of the Target Issue Type field is.
It will be possible though, using a custom post function.I suppose now you have more that one create sub tasks post functions in the same transition, one for every subtask issue type you want.
Therefore the single custom post function will merge all the post functions you have plus you will be able to add the condition you mentioned.
Hope that makes sense, if you need further assistance, ping me.
regards, Thanos
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.