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!
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.
A simpler approach that you might try is something like this:
Use ADDREMOVE option when editing the Labels field (ref yellow).
ITimK.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tyler Tate ,
Welcome to the community !!
You can create rule as below also.
in 1st step, keep the value for labels as blank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.