Creating a calculated field based on the number of labels?

Hello,

I am trying to create a calculated field that gives us the number of labels (from a custom label-type field) attached to the very same issue, but I am starting to doubt the possibility of it.

Any ideas of how I could go about it?

Thanks!

2 answers

1 accepted

1 vote

I'd use the script-runner add-on to populate the field with issue.getCustomFieldValue(cf).size()

I am using a calculated field to get the number of Labels, but if the value of custom field is null, it throws me an error "Target exception: java.lang.NullPointerException: Attempt to invoke method size on null value"

 

How do i overcome this error?

My formula:

<!-- @@Formula: ((issue.get("customfield_xxxx").size()).toString()) -->

I was able to manage null values.

Here is the formula:

<!-- @@Formula:
if (issue.get("customfield_xxxx")==null) return null;
return issue.get("customfield_xxxx").size(); -->

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

488 views 3 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you