clone an issue with all sub tasks
Hi,
Usually, I create a swim lane with 4 or 5 subtasks related to issue. From the issues page if I select the feature with all subtasks and try to clone them all the subtasks are getting created as subtasks of the original swim lane. Is there a way to clone a swim lane with its subtasks as one set or any other way to copy them as a I set.
thanks,
VK
Usually, I create a swim lane with 4 or 5 subtasks related to issue. From the issues page if I select the feature with all subtasks and try to clone them all the subtasks are getting created as subtasks of the original swim lane. Is there a way to clone a swim lane with its subtasks as one set or any other way to copy them as a I set.
thanks,
VK
Please sign in to leave a comment.
Unfortunately, it's not possible at the moment. I guess it can be implemented in future as an additional option, like 'Clone Tree' or similar.
Thank you for your suggestion!
Hi! Has the situation changed? I'd also find cloning a template issue tree useful.
Hi!
No, it has not changed, I'm afraid. Here's the related feature request: https://youtrack.jetbrains.com/issue/JT-34291 So far, it's not gotten much attention (votes), though it's not the only factor, it still matters. Feel free to vote for it, as it increases its priority and subscribes you to the email notifications. To do so, sign in to Jetbrains Youtrack: https://take.ms/41YJh (screenshot)
I'm new to YouTrack and immediately ran into this issue as well.
I created a custom workflow implementation that does this. See https://youtrack.jetbrains.com/issue/JT-34291 for details. My implementation is recursive, so it'll clone a whole tree of subtasks, plus it'll add "(Clone)" to the summary of the top-level issue.
The only thing I didn't created as a "cloned" link (like you might have in JIRA). I haven't learned how to detect whether or not a certain link type exists or not, but if I did, I'd check to see if "Cloned" exists and if so, then add a link for the top-level parent.
Hi Trev, you can use `IssueLinkPrototype.findByName(name)` method as described here
Cool Anna Zhdan, thanks for the pointer. I tried using that, but kept getting an error and I'm not sure what I did wrong.
I created a link type called "Clone" with outward name = "cloned to" and inward name = "cloned from".
Then I added the following logic to my workflow:
Here's the full workflow I was trying in case that helps:
Trev could you please attach logs of this workflow rule? They can be found in the lower panel in workflow editing UI. Could you please also attach a screenshot of your Issue Links Settings page?
Anna Zhdan, ah, I didn't see the workflow console. That's useful. The message I got there is pretty clear:
I could attack the stack trace, but we probably don't need it, we already know exactly where that's happening.
Strange that it's not finding IssueLinkPrototype because the editor found that it was available via workflow. I'm still a little new to javascript, so maybe I'm missing an important piece of syntax that's not obvious.
Here's a screen shot of my Issue Link Types settings page:
Trev
I'm sorry I didn't notice it before: it should be
instead of
That did the trick, thanks! I had to make one other tweak, which was to refer to the clone link type in the look up and refer to the outgoing link name in the adding of the link. All works now, thanks!
Hi!
Trev could you help me? I use your code in a workflow (thank you very much for your works!), but I need to use this feature that clone target and its subtasks, starting from a group of template task which I created specifically by assigning a particular value to a field named Category (Category = Template). When I use your function to clone the target issue with its subtask, I would like to automatically change the value of the Category Field to “Ticket” during the cloning process. Is it possible?
Marco Tarantino Hi! You'd need to add this code to the workflow:
newIssue.fields.Category = “Ticket”;
Hi Alisa Kasyanova, thanks a lot for your suggestion.
In my case the code is like below, where can I put your instruction to obtain my need?
Hello Marco Tarantino
In your code, this function goes through all subtasks of the original issue and copies them:
So you need to change the field value in the subtasks, you need to add this line after
newParent.links…
:If you need to change the field value in the parent issue, then here is where you copy an original issue:
So you need to add this line after that code block:
Hello Alisa Kasyanova, I follow your suggestions and all works fine!
Thank you very much!
Hi, I have one more questions: how can I modify the code that currently works to also change the project when I clone a task with its subtasks?
My goal is to switch the project from the current one, where I create all my template tasks, to another project, which is the actual operational project.
Here is my current code:
Marco Tarantino Add these lines to the code parts where you change the field values:
and
Where PRID - is the needed project's ID.
Alisa Kasyanova this one works perfectly too.
Thank you very much indeed
Alisa Kasyanova, I need your help again, and I hope you can assist.
I can now clone issues with parent and subtasks, change the project and category—everything works perfectly on that front. However, I've noticed that the Estimate field, which is private, isn't carried over in the cloned tasks. The new task is created perfectly but without the Estimate field value.
Here is a screenshot of the original task
and this is the one for the cloned task
What's strange is that if I use the clone function on a single issue (without parent or subtasks), the Estimate field value copies over correctly.
Any idea why this might be happening?
Marco Tarantino It is because the default clone action and your workflow use different methods to copy the task. You can add an additional code to copy the value in this field, like that:
newIssue.fields.Estimate = issue.fields.Estimate;
Alisa Kasyanova I added your instruction but not work: the parent don't have yet the estimate value.
This is my code now:
Hi Marco Tarantino!
By default, YouTrack sets the estimate of a newly created parent issue to the sum of its subtasks' estimates. Since the estimates are not set for the subtasks of ITG_GAS_TEMP-31, the estimate for ITG_GAS_AMS-76 is missing as well.
You can work around that by, say, tagging cloned parents to then update their estimates within an on-schedule rule. However, it seems that providing estimates for subtasks might be a more straightforward approach.
Hi Julia Bernikova! thank you for your explanation.
By your suggestion I set in the template issue the estimate value for all subtask and now the parent show the sum of its subtasks' estimates. Effectively when I clone the parent now I don't have any problems.
If I may, I would make another request.
By viewing my current workflow code, which I report below, I'm using Alisa Kasyanova suggestion to clone the Category fields:
and this for subtask
During the use of the workflows, I noticed that the issue has some problems with the Category field. The cloned Category field is set with a wrong value because when I open the cloned task, I see 2 values, as shown in the following image:
Another problem is that the cloned task does not have the Ticket Type field, which was present in the original task Template
In the cloned task, with the errorm, this field appears only if I select the second value “Ticket” for the Category field.
Below:
I tried these instruction in the code to also clone Ticket Type field from the issue template to the cloned Issue, but it doesn't work:
Hi Marco Tarantino,
It seems that the “Ticket” field behavior is caused by the script setting the fields for an issue copy before moving it to a different project. Instead, I'd suggest creating the issue copy in the needed project right away by passing the project as the
copy
method parameter like this:You can then remove the line that sets the
newIssue.project
property.To set the “Ticket Type” field, access it by the exact name via
newIssue.fields["Ticket Type"]
:Please apply both changes to creating a subtask as well.
Hi Julia Bernikova, thank you so much for your suggestion. Everything works perfectly now!
Thank you for the update, I'm very glad to hear it works now! 😊