Forums

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

How to count lines in a Free Text Field for a Scripted Field?

John Colton
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!
June 25, 2013

I want to populate a Scripted Field with the count of a Free Text Field.

What should the last line of this script be?

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.customfields.manager.OptionsManager;
 
def componentManager = ComponentManager.instance;
def customFieldManager = componentManager.getCustomFieldManager();
def RelatedCasesField = customFieldManager.getCustomFieldObjectByName("Related Cases");

// return (RelatedCasesField.count());

1 answer

0 votes
PhilB
Contributor
June 25, 2013

I think you're going to have to count the number of CR/LF charaters. Not sure of the exact syntax but, something like int count =StringUtils.countMatches(RelatedCasesField,"\n");

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events