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

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

Larry Katz April 8, 2021

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

4 answers

1 accepted

0 votes
Answer accepted
bmccoy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 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

Larry Katz April 19, 2021

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
Atlassian Team members are employees working across the company in a wide variety of roles.
April 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

Larry Katz April 26, 2021

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!

0 votes
Haddon Fisher
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 7, 2022

Hey Larry,

I was able to do this in Cloud by:

- Creating a custom field to hold my project names and keys. I used a multi-select, since I need the ability to create multiple tickets, but I tested using a single select and it works the same. My naming convention is "TEAM NAME (PROJECT KEY)"

- After my trigger and conditions, I use the "Advanced Branching" option within the "Branch" section to create a new smart value. I call it "project" and it is equal to:

  • {{#issue.Participating Teams}}{{value.replaceall("(.*)(\()(.*)(\))","$3")}}{{/}}
  • This takes each value of "Participating Teams", does a regex match to find the project key between the parenthesis, and returns it.

Screen Shot 2022-03-07 at 10.47.34 AM.png

- Underneath this branch, I have a "related issues" JQL condition to make sure I don't already have a ticket created in this project, linked to this issue using the relationship I use for these, and with the same summary. It checks to make sure there is NO matches to this search:

  • project = {{project}} and summary ~ "{{triggerIssue.summary}}"

Screen Shot 2022-03-07 at 10.47.44 AM.png

- If this condition is met, I then use a "create issue" action to make the new issue with the field values I want. In the UI dropdown I leave project set to "Same Project" but in the "More Options" expand, I add the following to the "Additional Fields" box:

  • {

    "fields": {

    "project":{

    "key": "{{project}}"

    }

    }

    }

 

screencapture-enterprisebp-sandbox-108-atlassian-net-jira-settings-automation-2022-03-07-10_47_57.png

 

It would be really nice to be able to just use a smart value directly though - I am not sure if that other ticket survived absorption into Atlassian, so I also put JRACLOUD-78577

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 16, 2021

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 8, 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🤔 ??

Laura Campbell _Seibert Media_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 9, 2021

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
AUG Leaders

Atlassian Community Events