Create a automation to copy labels from another issue
Asked by Devashish Kedar:

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/340744i70F3F62288A489E8/image-size/large?v=v2&px=999 "image.png")![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/340745i4AE4C945F5D3D0E1/image-size/large?v=v2&px=999 "image.png")![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/340747iE52896E07439A9DF/image-size/large?v=v2&px=999 "image.png")

I'm working with two sets of data, Story 1 and Story 2. In Story 1, I have an array that contains around 6 to 7 labels. My task is to fetch these labels and then append them to Story 2. If I run into any issues, like errors or unexpected outcomes, I'll need to provide more details to get help with resolving them.


Answers:
author: Bill Sheboy
body: Hi [@Devashish Kedar](/t5/user/viewprofilepage/user-id/5563931) -- Welcome to the Atlassian Community!

Rather than branching to add the labels, I recommend using [list iteration](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/#Combined-function-examples) to add all of them in on edit issue action with [advanced edit with a JSON, update](https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Labels).

For example:

* trigger: manual, to get your sourceIssue
* action: lookup issues with JQL of key = {{userInputs.sourceIssue}}
* smart value condition:
  * first value: {{lookupIssues.first.labels.size}}
  * condition: greater than
  * second value: 0
* edit issue: using advanced edit with JSON

```
{
  "update": {
    "labels": [
      {{#lookupIssues.first.labels}}
        { "add": "{{.}}" }{{^last}}, {{/}}
      {{/}}
    ]
  }
}
```

Kind regards,  
Bill


author: Rudy Holtkamp
body: Hi [@Devashish Kedar](/t5/user/viewprofilepage/user-id/5563931) \& welcome to the community,

In your rule I don't see where you make a distinction between story 1 and story 2. I assume that the key of story 1 is entered when you run the automation rule, but what about story 2?

If the are linked, then you should create a brand 'related issues' and make sure that Story 2 is selected there. Within that branch you can use an edit issue and select 'labels' as field.   
Then you can use the ... menu and choose copy. Then click on 'Copy labels from current issue'. Select trigger issue and check 'add to existing values'. (see image below).

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

Now the Story 1 labels are added to Story 2

comments: author: Devashish Kedar
body: I'm setting up a Jira automation where I have two issues, Story 1 and Story 2. Story 1, identified as ABC-1, has the labels 'aa' and 'bb'. Story 2, identified as ABC-2, has the label 'cc'.

The automation is designed to run on Story 2. When I initiate the automation on ABC-2, it asks for user input, which in this scenario is the issue key of Story 1 (ABC-1). After the user inputs this key, the automation should fetch the labels from ABC-1 and append them to ABC-2. As a result, the labels for ABC-2 should be updated to include 'cc', 'aa', and 'bb'.  

where ABC-1 and ABC-2 are not linked


Tags: atlassian-marketplace

atlassian-marketplace-cloud

cloud