Hello! I'm trying to use the JMWE "Create/Clone Issues Post Function" capability to clone an issue on a transition AS WELL as clone it's linked issues - all fields including custom fields. Essentially I want to create nearly an exact duplicate of an issue and it's linked issues. I'm using the JMWE so I can iterate and create multiples given certain criteria. Anyone done this before and willing to share how? I've successfully used this function to clone the 'parent' issue but struggling how to clone the linked issues and ensure they are linked to the clone of the "parent" issue.
Other info: Jira Server v8.5.3
Scriptrunner: 5.6.14.1-p5
JMWE: 6.2.4
Thanks in advance for your help!
Is this solution works for any one.
I have same requirement.
We have parent child issues between two projects. I want to clone complete structure of Parent- Child issues.
Kindly suggest
Hi Katrina,
Let's assume on the trigger of the transition "Clone now" you want to clone a parent and issues linked to it through "is related to" link type.
Clone Parent : Add the Create issue post-function to the "Clone now" transition.
Project
Clone linked issues: Add a "Transition Linked Issues" post-function configured as:
Create "Clone linked issues" transition
Clone linked issues: Add the Create issue post-function to the "Clone linked issues" transition
Select the Project as "Same as current issue"
Select the Issue Type as Calculated, with value
{{it.fields.issuetype.id}} |
Select the Link to new issue as "is related to"
Input the Summary as:
{{it.fields.summary}} |
In the iterator write the following script:
{{issue | linkedIssues( "clones" ) | first | linkedIssues( "is related to" ) | dump}} |
(note that "clones" here is the name of the reverse direction of the "is cloned by" link type used above.
Now when you trigger the transition "Clone now" the parent and its linked issues are cloned to the new project. Hope this helps.
Regards,
Radhika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much Radhika...gonna try and set this up now. Will let you know how it goes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Radhika Vijji _Innovalog_ your suggestion helped me overcome cloning the linked issues although I'm having issues with specific fields not cloning as expected; I'm working through that. The bigger issue is that the cloned linked issues are not linking to the cloned issue (they are linking to the original issue). Let me see if I can describe what I'm trying to achieve more clearly:
Project: the cloning is within the same project and all issue types I'm trying to clone are using the same workflow
Scenario: I create issue type = Feature and it has 2 linked issues of issue type Test (will call them Test A & Test B); link from Feature to Test is "tested by"; link from Test to Feature is "tests"
When I transition the Feature to "Ready for Development" I need the following issues to be created:
a) Issue Type "Story" - Clone of Feature with a Platform field = app1 and exact clones of Test A and Test B linked to Story 1 with "tests' link
b) Issue Type "Story" - Clone of Feature with a Platform field = app2 and exact clones of Test A and Test B linked to this Story with "tests' link
I hope that helps and thanks again for all your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Katrina,
My bad. I have provided you the answer for Jira Cloud and not Jira server. Here is what you need to do. Please try and let me know:
Clone Feature: Add the Create issue post-function to the "Ready for Development" transition.
Same as current issue
it
["app1","app2"]
Clone linked issues: Add a "Transition Linked Issues" post-function configured as:
Create "Clone linked issues" transition
Clone linked issues: Add the "Create issue" post-function to the "Clone linked issues" transition
Select the Project as "Same as current issue"
Select the Issue Type as Calculated, with value
it.issuetype.id
Select the Link to new issue as "tests"
Input the Summary as:
it.summary
In the iterator write the following script. Note that "clones" here is the name of the reverse direction of the "is cloned by" link type used above.
issue.getLinkedIssues("clones").first().getLinkedIssues("tested by")
Now when you trigger the transition "Ready For Development" two cloned Stories will be created for the feature with two linked issues each with the link type as "tests" (from test to Story)
Hope this helps,
Regards,
Radhika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi again @Radhika Vijji _Innovalog_
I seem to be much closer thanks to your help. I'm sure I have made an error so hoping you can walkthrough what I have set up and another set of eyes can find. Here's the error I am receiving:
Here's the Clone Feature "Ready for Development" transition set up:
And here's the Cloned Linked AC Test Issues transition set up:
I'm sure I'm doing something wrong here in terms of the iterator statement you provided....I've changed the linked issue type(s) in the statement multiple times using different values and still getting the same error. Thanks again so much for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Katrina,
I think the Stories itself are not created. Because the iterator script is wrong. It is currently:
["app1,app2"]
Which will try creating one Story with the Summary "app1, app2". But since you are trying to set the Platform field to "app1, app2" which likely is a select field, the option turns to be invalid and hence the issue cannot be created. Please fix the script to:
["app1,"app2"]
save the post-function, publish the workflow and retest.
Regards,
Radhika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Radhika Vijji _Innovalog_ the stories are created...that's an edit I did to the screenshot to not show what could be propietary info. That part of the script works fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Katrina,
Ok.
issue.getLinkedIssues("is the parent of").first().getLinkedIssues("tested by")
Can you fix these and retry?
Regards,
Radhika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Radhika Vijji _Innovalog_ hope you are well and healthy. I'm still working on getting this to work as needed. I made the changes you recommended and was able to get the Test issue types cloned but they link to the original Feature not the newly created Story issue types. I'm trying the Link Issues to Current Issue JMWE function but can't get this to work correctly. The result shows the correct issues that I want to link the Test issue type with but I keep getting an error. Hoping you can help. Thanks so much again for all your help!
For some reason I can't attach the screen shot. Here's how I've tried applying the groovy template for the JQL query:
${issue.getLinkedIssues("tests").first().getLinkedIssues("is the parent of")}
I get this error:
Errors: [Error in JQL Query: Expecting a field name but got '['. Did you mean 'cf['? (line 1, character 1)], Warnings: []
I've also tried this:
<%= issue.getLinkedIssues("tests").first().getLinkedIssues("is the parent of") %>
and get the same error.
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.