Forums

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

Can limit the number of characters in the summary field in JIRA? with ScriptRunner?

StephanieC
Contributor
November 3, 2021

Can limit the number of characters in the summary field in JIRA? We have  ScriptRunner... I read somewhere it might be possible with Behaviors. We export to a separate reporting database and a long summary hosed an import. 

2 answers

1 accepted

4 votes
Answer accepted
Joshua Sneed Contegix
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 3, 2021

Hi Stephanie,

It sounds like the reporting service needs to be updated to accept the data it is trying to intake, but I am a distant audience.

The code is stolen/modified from: https://community.atlassian.com/t5/Jira-questions/limit-character-on-custom-field/qaq-p/663064

def field = getFieldByName("summary")
if ((field?.value as String)?.length() > 70) {
field.setError("Length of the field should be less than 70 chars")
} else {
field.clearError()
}

(i) I did not test this.
(i) Chang the length (currently 70) and setError (currently the only sentence in quotes)

Here are some links to items that may help.

Cheers!

0 votes
Prem
Contributor
May 27, 2024

Hi @StephanieC 

 

You can achieve this by following these steps:

1. Go to the workflow and add a validation on the "Create" transition.
2. Add a validation via "Script Runner".
3. Use the following script:

issue.summary.split(' ').length >= 1 && issue.summary.split(' ').length <= 10
(Modify the number of words as per your requirement).

4. Test the script and add it.
5. Define a custom error message to help users understand the error.

Suggest an answer

Log in or Sign up to answer