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

John Colton 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 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