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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,554,787
Community Members
 
Community Events
184
Community Groups

Get project key of a linked issue in JQL

Hi, I'm doing some automation that aims to update an issue's field after the linked issue is closed. The field I want to update should have the value of the linked issue's project. I try to define a variable in the automation which should extract the project key, but for some reason this doesn't work.

For now I'm experimenting with getting some value and assigning it as a label to see if the value will be correct, and assign value to the variable to be {{project}}, but it doesn't work. Is this the correct way to extract the project's key or it's something else?

Screenshot 2023-05-10 at 17.25.50.png

2 answers

1 accepted

1 vote
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2023

Hello @Gergana_Damyanova 

What are the details of your Create Variable step?

What is written to the rule Audit Log for execution of the rule?

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2023

I think the problem is being caused because you are trying to set Labels in two different ways. You have specified JSON code for setting the Labels field, and you have also specified that you want to set it above that using the "Type to find value" option.

Screen Shot 2023-05-11 at 7.37.58 AM.png

 

You actually don't need the JSON text at all. You can use a smart value in the "Type to find value" area.

Before addressing how to do that, though, do you want to overwrite all existing labels in the Labels fields so that only this value is there, or do you want to add this label to the field and preserve all the values that might already be there? You can use this option to specify what you want to do. By default SET is the option that is used.

Screen Shot 2023-05-11 at 7.42.03 AM.png

 

Then, to add add the value from your variable, click in the field and start typing the smart value. Click on the Smart value '{{... area to have what you typed in inserted into the field.

Screen Shot 2023-05-11 at 7.45.28 AM.png

Thanks for the detailed explanation @Trudy Claspill !
I don't think that is the issue, because if I changed the smart value for example with {{issue.key}}, this setup works and a label was added with the key of the issue.

Sure I can use the the GUI to select the field, but I think the JSON gives more visibility if you have to set up more fields.

My problem is that I can't extract the project key of the issue. Playing with the label is just a way to see if I can do that, otherwise the field I want to update is a custom one. 

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2023

Oh, I see.

I would suggest that you use the substringBefore function to pull the project key from the issue key.

{{issue.key.substringBefore("-")}}

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#substringBefore-String-separator- 

Like Gergana_Damyanova likes this

Oh, this is such a nice workaround, haven't thought of that!
Thanks a million @Trudy Claspill , this is what I was looking for!

Like Trudy Claspill likes this

Hey @Trudy Claspill 

I tried replying in the thread of your answer, but I constantly get some strange errors, so will continue here.

 

Here are the definitions of the variable and the label update action

Screenshot 2023-05-11 at 15.19.51.pngScreenshot 2023-05-11 at 15.27.22.png

 

In the Audit log I get an error the label can't contain spaces but I struggle to see where these spaces actually are.

The label 'SmartProjectBean ...  can't contain spaces. (labels))

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events