Jira Automation - Creating a clone ticket from company-managed to team-managed
Asked by Abi Williams:

Hey everyone i was wondering if anyone can assist me with an issue.

We have two teams who are working on the same project. One team uses team-managed and the other team uses company-managed. We havent changed anything from default tickets (tasks, stories etc) minus one were it is called release deployment. I have changed a few of the columns but i am not sure

I am trying to create an automation where if something on company-managed is created under an parent (epic) it will be cloned onto the team-managed project using this logic below. This is coming from company-managed board.

![Screenshot 2024-05-09 133226.png](/t5/image/serverpage/image-id/322876i9534681BBDD814AA/image-size/large?v=v2&px=999 "Screenshot 2024-05-09 133226.png")

![Screenshot 2024-05-09 140158.png](/t5/image/serverpage/image-id/322878i5AF22743D250D9C6/image-size/large?v=v2&px=999 "Screenshot 2024-05-09 140158.png")

I currently have a testing project (our old board) that is company-managed but every time i create it i get this error: " Can not create issue in project/issue type 10112/10014" I aint sure what this means at all because i aint getting enough info to understand what this means.

![Screenshot 2024-05-09 134348.png](/t5/image/serverpage/image-id/322877iFE037E16A79E374B/image-size/large?v=v2&px=999 "Screenshot 2024-05-09 134348.png")

Any help would be grateful. I aint the biggest Jira expert so i will need info on how find things if you require additional info.


Answers:
author: Bill Sheboy
body: Hi [@Abi Williams](/t5/user/viewprofilepage/user-id/5492988) -- Welcome to the Atlassian Community!

Team-managed projects (TMP) have their own configurations and types, different from the shared ones for company-managed projects (CMP). That error indicates using the Issue Type of "Same issue type" will not work with the TMP, and so it shows the specific issue type id values which have the problem.

Please try selecting the specific issue type from the dropdown list to see how that helps.

Kind regards,  
Bill

comments: author: Abi Williams
body: Morning [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

The company-managed project will use both stories, tasks and spikes for this project hence why i wanted to keep it as the "same issue type" because i figured it will copy over easier.

I tried checking to to task as a test and go another failure. Apparently it didnt like the story points so i removed this too.

It now looks like this.

![Screenshot 2024-05-10 094510.png](https://community.atlassian.com/t5/image/serverpage/image-id/323030i1083710AD475AFF8/image-size/large?v=v2&px=999 "Screenshot 2024-05-10 094510.png")

And these were the errors:

![Screenshot 2024-05-10 094242.png](https://community.atlassian.com/t5/image/serverpage/image-id/323031i63FFDC8FD71D7F46/image-size/large?v=v2&px=999 "Screenshot 2024-05-10 094242.png")


author: Bill Sheboy
body: Regarding story points:

* company-managed projects use the "Story points" field, and
* team-managed projects use "Story point estimate".

Please select the correct field from the dropdown list for the TMP issue, supplying the value as {{issue.Story points}} to copy it. However...

Regarding issue types, this is a known problem for cloning issues between TMP and another project...even two different TMPs: <https://jira.atlassian.com/browse/AUTO-410> The defect is intermittent: in my test site, the Task issue type works but the Story one does not :\^(

Two possible work-arounds to try:

* Instead of Clone Issue, use the Create Issue action, manually selecting and copying each field. This will require using an if / else structure on the trigger issue's type so the correct issue type may be selected explicitly in the Create Issue action.
* Using the same if / else structure on issue type, except call the REST API create issue function with the Send Web Request action


author: Abi Williams
body: Afternoon [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

TIL about story points. They don't specifically highlight it easier between team vs company-managed projects in regards to fields but it might be being picky!

AUTO-140 would explain the issue then. Thank you for finding this.

I have figured out to do method 1 and it is working perfectly. Thank you very much! Only thing i am not sure about is how to do subtasks on tasks? Do you have any advice on how to do this?


author: Bill Sheboy
body: Subtasks are challenging for cloning in rules, and one approach to try is:

* after creating the new Task (i.e., the new parent), save the key {{createdIssue.key}} using the Create Variable action
* branch to the trigger issue's subtasks
  * using the Create Issue action again, re-create each one, setting the parent to the saved key in the created variable

This method will not preserve the order of the subtasks from the source issue because branches which could be on more-than-one-thing are run in parallel and asynchronously.


author: Abi Williams
body: Sorry do you have an example of this? Not entirely sure how to do this. I have created the variable but not sure how to branch to the trigger on the issues subtasks?

I am not worried about the order of sub-tasks as we will coordinate it between the teams but thank you for the additional info.


author: Bill Sheboy
body: Perhaps try extending your original rule, like this, with the changes in **bold** font:

* trigger: issue created
* **action: re-fetch issue (I recommend adding this after the Issue Created trigger to prevent racetrack error / timing problems.)**
* condition...on the project
* condition...on the parent key
* action: create issue (to "clone" the trigger issue)
* **action: create variable**
  * **name: varCloneKey**
  * **value: {{createdIssue.key}}**
* **branch: on subtasks**
  * **action: create issue, of type subtask to "clone" it, and setting the parent field to {{varCloneKey}}**


author: Abi Williams
body: I got this but i dont think it is right?![Screenshot 2024-05-13 155517.png](https://community.atlassian.com/t5/image/serverpage/image-id/323359iBD3FDC436E9E6440/image-size/large?v=v2&px=999 "Screenshot 2024-05-13 155517.png")


author: Bill Sheboy
body: The rule editor does not always make it easy to see what is possible :\^)

In the Create Issue action for the parent field:

* type in the smart value for your variable: {{subtaskvariable}}
* it will appear below the field as you type
* select it, and that will use it in the action for the parent


author: Abi Williams
body: Hello [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

Sorry been super busy so i have been unable to do anything until now but i have reattempted this but it isnt working? Im pretty sure im doing something wrong but i cannot see my error.

![Screenshot 2024-06-07 161603.png](https://community.atlassian.com/t5/image/serverpage/image-id/328643iA21BB4E42E26B892/image-size/large?v=v2&px=999 "Screenshot 2024-06-07 161603.png")![Screenshot 2024-06-07 161637.png](https://community.atlassian.com/t5/image/serverpage/image-id/328642i43FF21719776A6DB/image-size/large?v=v2&px=999 "Screenshot 2024-06-07 161637.png")


author: Bill Sheboy
body: When cloning the subtask, please set the **Parent** field, not the Epic Link field, to that created variable for the newly cloned Task.


author: Abi Williams
body: Tried again and got this error?

![Screenshot 2024-06-10 122245.png](https://community.atlassian.com/t5/image/serverpage/image-id/328901i4CDC2784BFA44622/image-size/large?v=v2&px=999 "Screenshot 2024-06-10 122245.png")![Screenshot 2024-06-10 122301.png](https://community.atlassian.com/t5/image/serverpage/image-id/328899iFC27E877834364C4/image-size/large?v=v2&px=999 "Screenshot 2024-06-10 122301.png")![Screenshot 2024-06-10 122411.png](https://community.atlassian.com/t5/image/serverpage/image-id/328900iC88C742083B54C94/image-size/large?v=v2&px=999 "Screenshot 2024-06-10 122411.png")


author: Bill Sheboy
body: I just tried again and creating a subtask with a parent specified by a variable still works.

Two things to check:

* Before you try to create the issue, write that created variable to the audit log to confirm in contains what you expect
* If it does not, please post an image of the Create Variable action where you create it to determine if the value and smart value are correct


author: Abi Williams
body: I know it is something i am doing wrong but not entirely sure what.

Not sure how to write something to the audit log.

Here is the screenshot of the created variable.

![Screenshot 2024-06-10 162151.png](https://community.atlassian.com/t5/image/serverpage/image-id/328962i5D8FBE99D37432D7/image-size/large?v=v2&px=999 "Screenshot 2024-06-10 162151.png")


author: Bill Sheboy
body: The create variable action looks correct.

There is a log action which allows writing text to the log: <https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Log-action>

If you write that variable to the log after it is created that may help. Perhaps something like:

```
the clone key is: {{varCloneKey}}
```

If that shows as empty, something is wrong with *where the variable is created*.

To check that, please post an image of your complete automation rule, in *one single, continuous image*. To do that, you may need either a scrolling browser capture tool or browser addon.


author: Abi Williams
body: I have noted another weird issue. Every time i create a task it doesnt copy onto the board. There will be some tasks without subtasks. Spike, bugs, stories etc are all working fine but not tasks on their own and tasks with subtasks.

Update: just tried it on bugs and not working either. Something isnt right with the ordering i believe.

![Untitled.png](https://community.atlassian.com/t5/image/serverpage/image-id/329111iE60ABA10AE7E9FF4/image-size/large?v=v2&px=999 "Untitled.png")![Screenshot 2024-06-11 112235.png](https://community.atlassian.com/t5/image/serverpage/image-id/329112iC851698889BC432E/image-size/large?v=v2&px=999 "Screenshot 2024-06-11 112235.png")


author: Bill Sheboy
body: If you compare the log to the rule steps, you will see **the Task issue create is failing**.

And so the created variable is empty as there was no issue created.

Please review the image of that action as I suspect it is trying to set the parent, but it should not for your scenario. Setting the parent should only happen for the Subtask create in your scenario.

The log also shows that the trigger issue did not have any Subtasks and so the branch did not proceed. Did you expect that?


author: Abi Williams
body: I did note that but im not understanding why. The tasks are being created as i can see them on the board okay. I also attempted to create a bug and now that isnt working where it was working before i introduced sub-tasks.

For testing i created a task then add the subtasks afterwards so no i wasnt expecting that.


author: Bill Sheboy
body: Given what you describe, I would expect that behavior for the branch:

* your rule is triggered on issue created, and so starts soon after the Task is created...
* but it runs so quickly the subtasks are not available yet when the branch is reached (as you are still adding them).

At this point, I recommend working with your Jira Site Admin and contacting Atlassian Support to take a look. They may see something we are missing.

You appear to be on a paid Jira license, and so your admin can submit the ticket here: <https://support.atlassian.com/contact/#/>


author: Abi Williams
body: Okay thank you very much for your help.

I will run the automation without subtasks so i got something but i will speak to Atlassian and see what can be done.


Tags: cloud

jira

jira-cloud