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,558,797
Community Members
 
Community Events
184
Community Groups

In Jira Automation, how do I add to a component, and not clear the existing value?

I am trying to make a rule where when an issue is assigned to a specific set of users, the component field is updated to include a specific component, let's call it "kitttens". I got this automation working, however, it's replacing the values in the component field with "kittens". I want it to say "kittens" and "puppies".

1 answer

Well this is embarrassing, I solved my own problem =)

 

In case anyone else needs it, the answer in the automation is edit issue-> components-> "kittens" and "copy from issue"

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 17, 2022

Glad you found it! Sorry we couldn't get to you before then.  ;-)

How do you enter a component in addition to Copy Components from Current Issue? My UI only allows me to select Copy Components from Current Issue and I can't enter anything else.

 

Screenshot 2023-01-22 231048.png

I am also looking for the answer to this. I want to add to existing values in the Components field. Right now my options are only Set or Copy. I would love the options to be the same as it is with Labels where you can specify Set, Add/Remove, or Copy.

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.
Feb 08, 2023 • edited

Hi @Chad Vernon and @Karen Corbeill 

It appears you want to add additional components, rather than replace or copy them.

To do that, you would use the advanced edit with JSON options.  Unfortunately I do not believe you can add just one component value with JSON, like with Labels.  Instead you must capture all the existing ones first, add the additional one, and then set them all at once.

Here is a rule which can do that for Jira Cloud.  The same can be done with Server/Data Center versions by eliminating the created variables and doing this in one step.

  • trigger: select your trigger which provides the issue.  Let's assume Manual trigger for now.
  • action: create a variable for the current components as JSON
    • variable name: varCurrentComponents
    • smart value: {{#issue.components}}{ "name": "{{name}}"} {{^last}}, {{/}}{{/}}
  • action: create another variable which adds the new component
    • variable name: varNewComponents
    • smart value: {{varCurrentComponents}} , { "name": "My Added Component"}
  • action: edit issue, selecting the More Options section for advanced edit
{
"fields": {
"components" : [ {{varNewComponents}} ]
}
}

 

How this works...

  1. Gather the current components, and iterate over them as a list of values, and put them into a JSON format
  2. Add the new component, also in JSON format
  3. Finally set the components field to replace the values

 

Please try that and let the community know if you need further help with this.

Kind regards,
Bill

Like # people like this

This looks great! I'll have to give it a try. Thank you so much!

Like # people like this

How do you deal with the case where varCurrentComponents is empty so the resulting json in the last action is invalid?

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.
Apr 03, 2023

Hi @Chad Vernon 

You can use the conditional handling to test for the empty value, and only include/use the JSON when needed.  This could also be done with a rule condition.

Kind regards,
Bill

I ended up using:

{"name": "New Component To Add"} {{#if(not(varCurrentComponents.isEmpty))}}, {{/}} {{varCurrentComponents}}
Like John Funk likes this

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