# Setting a value based on a labels (jira - \> Azure)

**URL:** <https://community.exalate.com/t/setting-a-value-based-on-a-labels-jira-azure/4684>\
**Category:** General Questions\
**Tags:** migrated\_question, jira-server-azure\
**Created:** [November 4, 2024, 7:16am UTC](https://community.exalate.com/t/setting-a-value-based-on-a-labels-jira-azure/4684 "2024-11-04T07:16:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 7:16am UTC](https://community.exalate.com/t/setting-a-value-based-on-a-labels-jira-azure/4684/1 "2024-11-04T07:16:17Z")

</div>

_Originally asked by Daniel Estermann on 21 April 2021 [(original question)](https://oldcommunity.exalate.com/questions/25071603)_

* * *

We try to set the Area Iteration Path in Azure based on the Labels received from Jira on prem. If workItem.labels contains the Tag/label “Cockpit” then it should set the value for iterationPath to “xxx” else its “DGB” set it to “yyy”. Unfortuanatly I always get the default path…

Does anyone have a idea what i’m doing wrong? 😉

Many thanks,

Daniel

if (workItem.labels.contains(“Cockpit”)) {  
workItem.iterationPath = “ExtensionTest\\Cockpit”}  
else if (workItem.labels.contains(“DGB”)) {  
workItem.iterationPath = “ExtensionTest\\DGB”}  
else {  
workItem.iterationPath = “ExtensionTest\\Incidents”}

 ![](https://europe1.discourse-cdn.com/flex018/uploads/exalate1/original/1X/4a6cf73d1865eeb78fa33a63924ab098f85ecf58.png)

* * *

---

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 7:16am UTC](https://community.exalate.com/t/setting-a-value-based-on-a-labels-jira-azure/4684/2 "2024-11-04T07:16:18Z")

</div>

_Answer by Francis Martens (Exalate) on 21 April 2021_

You can use a 'debug statement to see what path is being followed like

```auto
if (workItem.labels.contains("Cockpit")) {
     debug.error("Should be cockpit because workItem.labels '${workItem.label}'")
     workItem.iterationPath = "ExtensionTest\\Cockpit"}
else if (workItem.labels.contains("DGB")) {
     debug.error("Should be DGB because workItem.labels '${workItem.label}'")
     workItem.iterationPath = "ExtensionTest\\DGB"}
else {
     debug.error("Is incidents because workItem.labels '${workItem.label}'")
workItem.iterationPath = "ExtensionTest\\Incidents"}

```

With this, when ADO receives a message from Jira, an error will be raised containing details about the branch taken and the value of the workItem.labels.

You will have to take it from there.

* * *

#### Comments:

> **Daniel Estermann commented on 22 April 2021**
>
> > Hi Francis,
> 
> Thanks for the hint. Seems like the value in workItem.Labels is not what i expected. My understand was, that the workItem.labels is first mapped with the replica.labels and that I can then work with the mapped content (labels).
> 
> As I’m not a dev this is obviously wrong. _(old community)_
> 
> How do i put the content (labels) into a field where the script below can read it?
> 
> Many thanks for your help  
> Daniel
> 
> javax.script.ScriptException: com.exalate.api.exception.IssueTrackerException: Is incidents because workItem.labels **‘[com.exalate.basic.domain.hubobject.v1.BasicHubLabel@1081f]’**
> 
> workItem.summary = replica.summary  
> workItem.description = replica.description  
> workItem.priority = replica.priority  
> **workItem.labels = replica.labels**  
> workItem.attachments = attachmentHelper.mergeAttachments(workItem, replica)  
> workItem.comments = commentHelper.mergeComments(workItem, replica)
> 
> if ( **workItem.labels**.contains(“Cockpit”)) {  
> debug.error(“Should be cockpit because workItem.labels ‘${workItem.labels}’”)  
> workItem.iterationPath = “ExtensionTest\\Cockpit”}  
> else if ( **workItem.labels**.contains(“DGB”)) {  
> debug.error(“Should be DGB because workItem.labels ‘${workItem.labels}’”)  
> workItem.iterationPath = “ExtensionTest\\DGB”}  
> else {  
> debug.error(“Is incidents because workItem.labels ‘${workItem.labels}’”)  
> workItem.iterationPath = “ExtensionTest\\Incidents”}

> **Francis Martens (Exalate) commented on 22 April 2021**
>
> > Daniel Estermann
> 
> How does the label look like what is the output of the debug.error?
