Hello, I'm trying to count how many dates of format
YYYY_Tx
exist in a Labels field and save this as a numeric value in another field. I try the below, but I keep getting erros. Any help on what is wrong? So the Labels has: 2024_T3 , 2025_T1 , etc
The error I get:
Unable to render smart values when executing this rule:
{ "fields": { "Overall effort": "{{issue.Labels.match('.*(\\d{4}_T\\d).*').size}}" } }
Hi @Menia Laina
To count how many labels in the format YYYY_Tx
exist in your Labels field and save the count in another field, your current smart value expression is close but has a slight issue.
The match
function is being applied incorrectly in your smart value expression. Instead of using .match
to count occurrences, you should use .filter
to isolate the labels matching the desired format and then count them using .size
.
Here’s the corrected expression:
{
"fields": {
"Overall effort": "{{issue.labels.filter(label -> label.match('\\d{4}_T\\d')).size}}"
}
}
issue.labels
: Refers to the Labels field, which is a list of strings..filter(label -> label.match('\\d{4}_T\\d'))
: Filters the labels, keeping only those matching the format YYYY_Tx
using a regex pattern..size
: Counts the number of matching labels.Overall effort
field.Let us know if you need further clarification or additional help! At Getint, we specialize in integrations and optimizing workflows, so feel free to reach out for guidance.
What is the source of the content you posted?
If it is from a bot / AI-tool, please see the community guidelines regarding the disclosure of such content in your post's wording:
https://community.atlassian.com/t5/custom/page/page-id/rules-of-engagement
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.
@Renata_Getint We noticed this response has a distinct AI-like formatting. While we're all for embracing new tech, we want remind everyone of the Atlassian community guidelines and Responsible Tech Principles. Put simply, AI can be a great tool for polishing, but your real-world knowledge is what our community values most. We ask the core of your contributions to come from your own expertise.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Menia Laina -- Welcome to the Atlassian Community!
The problem is the use of single-quotation marks, as the match() function expression takes double-quotation marks.
What is the type of your field: numeric or text?
If the field is numeric, please change the expression to this:
{
"fields": {
"Overall effort": {{issue.Labels.match(".*(\\d{4}_T\\d).*").size}}
}
}
If the field is text, either:
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.
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.