Automatically Add and Update Labels Based on the "Capability" Field in Jira

Ivan
Contributor
January 27, 2025

Hi everyone,

I’m looking to create an automation in Jira that automatically updates labels based on the value of the Capability field. Here’s the goal:

  1. Check if a label matching the pattern "|Capability" already exists. If it does, remove it.
  2. Add a new label reflecting the value of the Capability field.
  3. It's also important that the labels have no spaces in between the letters so it should be : |CapabilityAsset/OT and not |Capability Assset/OT

For example:

  • If the Capability field is set to Data Analytics, the label |CapabilityDataAnalytics should be added.
  • If Capability is set to Asset/Assetbetrieb, the label |CapabilityAssetBetrieb should be added.

Its important 
This logic should work for the following Capability values:

  • Asset/Assetbetrieb
  • Asset/Asseterrichtung
  • Asset/Assetmanagement&-planung
  • Asset/HSSE, FM
  • Asset/OT
  • Asset/Verfahren
  • Cross Functions/Cyber Security
  • Cross Functions/Digitaler Arbeitsplatz
  • Cross Functions/Governance
  • Cross Functions/IT
  • Cross Functions/Kommunikation
  • Cross Functions/Personal
  • Cross Functions/Projektmanagement
  • Cross Functions/Recht
  • Cross Functions/Stakeholder Management
  • Data Analytics
  • Energiesystem/Operative Energiewirtschaft
  • Energiesystem/Systemanalyse
  • Energiesystem/Systembetrieb
  • Energiesystem/Systementwicklung
  • Energiesystem/Systemmanagement
  • Energiesystem/Veröffentlichung
  • Finance
  • Netzanlagendatenmanagement/GIS
  • Netzanlagendatenmanagement/Netzmodelle
  • Netzanlagendatenmanagement/Stammdaten

I’d like to achieve this using Jira Automation, but I’m also open to solutions using the REST API.

Any advice, ideas, or examples would be greatly appreciated! 😊

 

 

1 answer

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.
January 27, 2025

Hi @Ivan 

What have you tried thus far to solve this need?

 

If you have a rule and it is not working as expected, please post the following for context to help the community offer suggestions:

  • an image of your complete rule, in one single image file
  • images of any relevant actions / conditions / branches
  • an image of the audit log details showing the rule execution
  • explain what is not working as expected

 

If you have not started a rule yet, I encourage you to try to do so.  Successfully using automation rules requires learning and experimentation.  And, the Atlassian Community is a place for people to collaborate and learn.  It is not to provide turnkey solutions for specific requests.

To get you started creating your rule, please see this introduction: https://confluence.atlassian.com/automation/get-started-with-jira-automation-993924596.html

Then for your scenario, consider using the match() function with a regular expression to both detect the labels to add and to remove: https://confluence.atlassian.com/automation/jira-smart-values-text-fields-993924863.html#Jirasmartvaluestextfields-matchmatch()

Additionally, if / else condition blocks may help for the differences in behavior for some of the different values.

 

Finally, one of the examples you describe might not be possible:

If Capability is set to Asset/Assetbetrieb, the label |CapabilityAssetBetrieb should be added.

This shows dynamically changing the capitalization for the label text.  This would only be possible if the prefix text (e.g., Asset) is known and never changes.

 

Kind regards,
Bill

Ivan
Contributor
January 28, 2025

Hey Bill,

I’ve tried several approaches to automate updating labels in Jira based on the Capability field, but so far, I haven’t had much luck. Here’s what I’ve done:

  • Smart Values:
    I worked with smart values in Jira Automation to dynamically create and update labels. I tried removing any existing labels that matched the |Capability pattern and adding new ones without spaces or special characters.

  • YAML Code:
    I experimented with YAML-like configurations for the automation rules, mapping values from the Capability field to the corresponding labels I wanted.

  • JQL Filters:
    I used JQL in the automation rules to find and remove existing |Capability labels before trying to add the new ones.

  • Other Workarounds:
    I also tried a bunch of combinations of smart value expressions like .replace(), .remove(), and string operations to format the labels correctly, but nothing seems to work as expected.

At this point, I’m stuck and can’t seem to get this working properly in our Jira setup. It feels like this issue might not be solvable with the tools we have here.

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.
January 28, 2025

Without seeing the specifics of the rule you are trying to use, it is difficult to know what is not working.  This is why I asked to see the rule, step details, and audit log.  If you cannot provide those, I recommend working with your Jira Site Admin for assistance.

 

I recommend starting with a simple rule to incrementally implement this scenario.

  • trigger: the Capability field changes
  • action: create variable, using the match() function to try extracting values from the Capability field
  • action: log the variable
  • action: log, again using the match() function to find any values in the Labels field to remove

Then test with various values of the Capability and Labels fields to test your regular expressions.

Suggest an answer

Log in or Sign up to answer