Create / clone issue when project name is smart value / dynamic
Asked by Alex Rouk:

Hello, community.  
Is there a way to create a new issue (or clone) without providing a specific project name?

In other words, i need a rule that can create an issue, while target project is based on a trigger' field value (assume that there is a field with the project key or name (tried both) provided by a user and can vary.

tried using smart values for both project and issue type and it fails on 'project name is required'.

i have a workaround in mind but i don't like very much.. (it requires a rule for each possible project, bunch of flags and complex maintenance )

thank you in advance!


Answers:
author: Tony Villa-Cruz
body: I think people are not seeing that this question has been answered, so I am re-posting [@Italo \[Modus Create\]](/t5/user/viewprofilepage/user-id/4314367) 's answer as an answer outside of the the other answers thread, because I found that this answer does in fact work!

[@Italo \[Modus Create\]](/t5/user/viewprofilepage/user-id/4314367) said:
> I was able to achieve this by using the **additional fields** to overwrite the Project that I need to create the issue.
>
> ![Untitled.png](https://community.atlassian.com/t5/image/serverpage/image-id/221185iE965C6968F914DA2/image-size/large?v=v2&px=999 "Untitled.png")
>
> In my case I have a custom field named "Activity" and the options are
>
> * Task A - **ASP**
> * Task B - **DSP**
> * ...
>
> The bold section is the project that the task should be created into, so I was able to do extract the project key using **substringAfter** and then use to as the project key.
>
> ```
> {
>  "fields": {
>    "project":{
>       "key": "{{issue.Activity.value.substringAfter("-").trim()}}"
>    },
>    "Parent link": "{{triggerissue.key}}"
>  }
> }
> ```

Hope this helps people find the answer! This was a big unlock for me!

comments: author: Andrej Goleniewski
body: Thanks a lot!


author: Simmo
body: Hi [@Alex Rouk](/t5/user/viewprofilepage/user-id/3616744) ,

Not sure which Automation you're referring to. But if you're referring to Jira Automation (formally Automation for Jira) then there is an option in the UI that will do what you want to acheive:

![createissue.png](https://community.atlassian.com/t5/image/serverpage/image-id/112298iDEC74733803EBF93/image-size/large?v=v2&px=999 "createissue.png")Cheers,

Simeon

comments: author: Alex Rouk
body: Thanks, [@Simmo](/t5/user/viewprofilepage/user-id/3608665) Yeah, that Automation :)

My issue is that I don't want (can't) to put a specific Project name because it is uncertain when i'm creating the rule. So i wanted either to use field's value there or a variable.

Is it possible?  

Thank you!


author: Simmo
body: Hi [@Alex Rouk](/t5/user/viewprofilepage/user-id/3616744) ,

Does the "same project" option not work for you? It will try to determine it based on the trigger context. So you shouldn't have to specify a project.


author: Alex Rouk
body: Thank you again, [@Simmo](/t5/user/viewprofilepage/user-id/3608665) .

it is not that simple..

Imagine i have a rule triggered from project A. The rule is supposed to create a new issue in *another* project (B, C, D..), based on a value of projectA_field. The value of projectA_field is entered by user.

For example, if projectA_field = "B", the issue will be created in B, if projectA_field="C", then in project C.   
Project A is kind of a hub, creating tickets dynamically in other projects

Hope this clarifies.

thanks!


author: Simmo
body: Hi [@Alex Rouk](/t5/user/viewprofilepage/user-id/3616744) , yeah I'm starting to get the picture now. Is it possible for you to share a few screenshots of how you have configured your rule so we can figure this out?


author: Alex Rouk
body: [@Simmo](/t5/user/viewprofilepage/user-id/3608665) , i can definitely share anything :) but I am not sure what can i share..

attached a dummy rule that covers my need.. hope it helps..

thank you again for the time and willingness to help. much appreciated!

![example.png](https://community.atlassian.com/t5/image/serverpage/image-id/112694iFEEA3616F63EC676/image-size/large?v=v2&px=999 "example.png")


author: Inactive Stephen
body: Hi [@Alex Rouk](/t5/user/viewprofilepage/user-id/3616744)

Did you ever work this out? I'm also trying to get this to work!

Ste


author: Matthew Patton
body: I've been working on a similar feature. I have a select field to select the project (eg customField_1). I matched the project name with the selections in that field. In Create issue action I put in {{customField_1}}. I get an error that meta data could not be created for project/issuetype. I've tried similar with Issue Type using a field {{customField_2}} with the value of "Story" and got the same error. It is as though these fields support smart value entries, but it doesn't seem to accept the values unless I'm doing something wrong. I've also tried values for key and the format ProjectName (key) that the selections show.

The workaround I am thinking of testing is using the send web request action to create issues based on smart values. Setting the payload would be the only hard part.


author: Blake Waud
body: [@Alex Rouk](/t5/user/viewprofilepage/user-id/3616744) [@Matthew Patton](/t5/user/viewprofilepage/user-id/4234437) [@Simmo](/t5/user/viewprofilepage/user-id/3608665) Did anyone ever figure this out? I am trying to accomplish something similar. The audit log shows the smart value I have in the Project field of the Create Issue action does match an existing project key, but the automation fails saying no key was provided.


author: Blake Waud
body: I was able to get my use case to work by using the PID instead of the key or name. I found the PID by navigating to the project's edit page, and it was in the URL. Somewhat cumbersome, but it worked.


author: Matthew Patton
body: Interesting, so you used the ID for both the Project and IssueKey Type(i assume no id here would go to the default issue type)? I haven't tried it. I ended up not having to pursue this further due to some changes in plan.

I have written scripts to create tickets, and seeing that the payload uses IDs, it makes sense for what Blake mentioned. Here is an example for POST.  
{  
"fields": {  
"project":  
{  
"id": "\<PID\>"  
},  
"issuetype": {  
"id": "\<typeID\>"  
},  
"customfield_1234": "value"  
}  
To make it more flexible you would probably send a Get request in Jira automation to get the id's using /rest/api/2/project/\<projectKey\>. The response to get the PID can be written something like {{webhookResponse.body.results.id}}  
If you only have a few projects it would be easier to have a select field with project names. The automation would trigger based on that field change\>IF/Else Block for each field value, then add the action to create issue for each field condition. The example below would create a Task in (CMOT) if Project Name = Project1, or Task in (DEM) if Project Name = Project2.  
![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/170700i178D47EA7A24FB45/image-size/large?v=v2&px=999 "Capture.PNG")


author: Blake Waud
body: Yes, that would make sense to add flexibility, but in this case, it's a hard configuration for me depending on an Insight object selected in a different field, so that object just has the project's PID as an attribute.


author: Thierry BLOCH
body: Hello,

This is exactly what i need to implement. If someone can show a step by step process, it will be very awesome.


author: Italo [Modus Create]
body: I was able to achieve this by using the **additional fields** to overwrite the Project that I need to create the issue.

![Untitled.png](https://community.atlassian.com/t5/image/serverpage/image-id/218014i9F6D63091EB55E59/image-size/large?v=v2&px=999 "Untitled.png")

In my case I have a custom field named "Activity" and the options are

* Task A - **ASP**
* Task B - **DSP**
* ...

The bold section is the project that the task should be created into, so I was able to do extract the project key using **substringAfter** and then use to as the project key.

```
{
 "fields": {
   "project":{
      "key": "{{issue.Activity.value.substringAfter("-").trim()}}"
   },
   "Parent link": "{{triggerissue.key}}"
 }
}
```


author: Tony Villa-Cruz
body: See answer outside of thread!