Hi All,
I am trying to return a count of all of the words in a multi-line text field using a "Calculated Text Field". Is there an in-built function to do this? The ".length" function returns the character count for the contents of the custom field. ".size" does not appear to work on the same custom field.
If there is not an in built way to do this, I was trying to loop through each character in the field looking for ' ' or '\n' which would indicate a new word, however this is error prone e.g. newlines appended to the end of the text.
Appreciate any guidance.
Regards
Hi,
Not sure what version of JIRA you are using and what add-ons you have installed, but as far as I know, this isn't possible out of the box. We've done a similar thing using the ScriptRunner add-on. We simply created a Script Field and have the following code in it:
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObjectByName('fieldName')
String cFieldValue = issue.getCustomFieldValue(cField)
if(cFieldValue) {
return cFieldValue.split().size()
}
return 0
Hope this helps.
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.