Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Clone to a Project where the Key is passed to a Smart Value from Trigger Issue

I found something similar to this, but there was no answer in a year
https://community.atlassian.com/t5/Automation-questions/Create-clone-issue-when-project-name-is-smart-value-dynamic/qaq-p/1494344

Is there a way to Clone a ticket into a project where the target value is passed from the trigger issue and parsed in a smart value? I've attempted this and it returned an error that nothing was provided.

The goal is:
from Jira Service Management i'm trying to keep the current ticket where it is, but if a developer wants to move into a different backlog for a release, they would choose a "Add to Development" transition in the workflow, and the automation would pick up the change to the field "Target Issue Type"

Per other conditions in the automation, the automation would create the clone into a project, which key is passed in from the screen the user selects from. (see screenshot)

it's more scalable for me to add the project keys to the dropdown for the user and pass them to the automation for the smart value to render it and create the ticket into that project.

We have 50+ projects and I don't want to make numerous if/else blocks to accomplish this.

I've tried the smart value for the custom field {{issue."Target Project Key"}} into the project dropdown but I get an error. 

Any work around here?

Screen Shot 2021-04-08 at 6.59.05 PM.pngScreen Shot 2021-04-08 at 6.59.31 PM.pngScreen Shot 2021-04-08 at 7.00.30 PM.png

3 answers

1 accepted

0 votes
Answer accepted
bmccoy Atlassian Team Apr 15, 2021

Hi,

It looks like we only accept Project IDs, not keys.  I've raised a ticket for this:

https://codebarrel.atlassian.net/browse/AUT-2194

As a workaround you could possibly add the project ID in the drop-down e.g.  "JTP [11094]" and then use our String functions to pull it out:

{{issue.Target Project Key.substringBetween("[", "]")}}

Cheers,
Brydie

Thanks I've tried a few variations of this, I just can not get this to work.

Screen Shot 2021-04-19 at 10.59.58 AM.png

Tried:

{{issue.”Target Project Key”.substringBetween(“[“, “]”)}}

{{issue.Target Project Key.substringBetween(“[“, “]”)}}

{{issue.Target Project Key.substringBetween(“(“, “)”)}}
{{issue.Target Project Key.substringBetween(“*“, “*”)}}

Dropdown value as JTP (10938), JTP [10938], JTP *10938*

nothing seems to work although from your suggestion and on 
https://confluence.atlassian.com/automation/text-functions-993924863.html

This solution should work fine.
{{issue.Target Project Key}} or  {{issue."Target Project Key"}} renders fine, but using in conjunction with the substringBetween() method, it does not for some reason. Should the entire JTP (10938) value be an actual string in the custom field? 

Example "JTP (10938)" instead of JTP (10938).

Per this:
https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#substringBetween-java.lang.String-java.lang.String-java.lang.String

This is already coming in a string.

bmccoy Atlassian Team Apr 20, 2021

Hi Larry,

What type of field is the "Target Project Key" is it a regular select list?  Looks like for select lists we need to grab the "value".  I've got the following working for me:

{{issue.Select CF.value.substringBetween("(", ")")}}

Cheers,
Brydie

Thanks, this totally works for my case for now while AUT-2194 is being considered to accept keys. Silly me I totally forgot how select menus act in terms of the value :) Appreciate the assist!

Hi @Larry Katz 

One work-around for this, albeit a slower one is to use the REST API to get at the Project ID from the name:

  • Once you have the project name from your custom field...
  • Make a webrequest action call to the REST API for get all projects
  • Parse the response using a regular expression, creating a Project Name/ID list in a created variable
  • Use the Match function with the target project name on the created variable to pull the ID you need 
  • Clone your issue using the ID

 

Best regards,

Bill

0 votes
Curt Holley Community Leader Apr 08, 2021

Interesting scenario.

Not sure it can be done as simply as you are thinking (happy and interested in being proven wrong though). 

Your "Add to development" screen is kinda as complex as doing a manual cloning process, so....

Best I can think of is:

Replace it with "manual trigger" based automation. This would really simple automation done per Project.

Pros: Easy to copy, edit project and create the next one. So not as hard as a 50 plus if else statement and easy enough to keep adding more as more projects are created

Cons: This would mean 50 plus manual trigger automation rules for people to scroll through. But if they all started with the relevant Project key, then..... Maybe it could work? 

It would also be a change in current (I presume) procedure.

It still requires some manual effort (arguably not any more than the "Add to development" screen though) and refactoring to keep in sync with new projects, archived/trashed projects. Again, similar to the maintenance effort of the "Add to development" screen.

 

Not sure how helpful I've been🤔 ??

Don't know if you absolutely need to find a solution with automation, but there are clone and move apps that are easier to configure and easy for users to use.

For example, Elements Copy & Sync could work for you by letting developers chose a copy recipe "Add to Development" where you've pre-configured the issue type and the user selects from the projects made available for the recipe.

You can see how it works in this video https://youtu.be/uxcOT2imgHQ

Like Simon Laffont likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Automation

New to Jira Automation - goodbye Cron (sort of), hello new project created trigger, new additions to

Hey Everyone! Simeon from the Automation team here. I'm delighted to share some new features and improvements that we are shipping to Jira automation (Cloud only). Firstly, @Sam Harding&nbsp...

2,837 views 10 23
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you