Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to use smart values to update labels for due date

Tyler Tate
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 14, 2024

I am at my wit's end here. I have been trying to write a very simple automation that can update an issues label when its due date has been changed. The format is MMMM-yyyy for the label based on due date. All I want to do is if an issue has its due date updated that 1 of 2 things will happen.

Let's say due date is 9/1/2024. 

1. If no due date exists then that's really easy to add a new label for that. 

2 (where I'm stuck). Let's say that I already have a label of September-2024 but now my due date update to 10/7/2024. I want a new label of October-2024 to be created and old label of September-2024 to be removed. 

I was doing a basic When: Value changes for Due date Then edit issue fields Labels. 

Adding a new label works fine with: 

{{issue.duedate.format("MMMM-yyyy")}}

but where I'm struggling is removing the old. I've tried the below but I can't seem to figure out what I'm missing. 

{{issue.labels.match("^(January|February|March|April|May|June|July|August|September|October|November|December)-\\d{4}$")}}

{{issue.duedate.change.previous.format("MMMM-yyyy")}}

Any help to point me in the right direction would be great!

3 answers

1 accepted

1 vote
Answer accepted
Tim Kopperud
Community Champion
August 14, 2024 edited

Hi @Tyler Tate, welcome to Altassian community.

You should treat labels as a list by using the syntax as described here Jira smart values - lists | Automation for Jira Cloud and Data Center | Atlassian Documentation

{{#labels}} {{/}}

Secondly, do not try to change the label found, but first remove it from the list and then you add the new label. 

Hope this guide you in the right direction. 

EDITED:

A simpler approach that you might try is something like this:

image.png

image.png

image.png

Use ADDREMOVE option when editing the Labels field (ref yellow).

ITimK.

Tyler Tate
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 15, 2024

Thanks a ton! I had to make a small modification to make it keep existing labels all I did there was change 'exactly matches regular expression' to 'contains regular expression' and then add a final action to add the new duedate after everything is done. 

Great to start the day with this after hours of frustration!

 

Like • Tim Kopperud likes this
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.
August 15, 2024

Hi @Tyler Tate -- Welcome to the Atlassian Community!

Adding to the other suggestions...

Rather than checking if the old label is present with the regular expression, why not just use the changelog entry to get the prior value, and always remove the label.  If it is not present, it will not throw a rule error.

Kind regards,
Bill

0 votes
Rilwan Ahmed
Community Champion
August 15, 2024

Hi @Tyler Tate ,

Welcome to the community !!

You can create rule as below also. 

in 1st step, keep the value for labels as blank

image.png

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.

Register today!
AUG Leaders

Atlassian Community Events