Restricts tickets being created with summary that contains a specific string

Michel saliba December 10, 2023

Hi All,

 

i have jira app (data center) Jira Data Center 9.12 and Scriptrunner 8.17.0 installed.

I have a project (type : IT service management ) with a default workflow Jira Service Management default workflow

I Have created a customer script validator associated to this poject for this project on Createe Transition in order to restrict the user to create a new ticket which have "test" string in summary 

The code is the below 

def summary = issue.summary

// Check if the summary contains the string "test"
if (summary && summary.toLowerCase().contains("test")) {
// Issue creation is not allowed
return "Issue creation with 'test' in the summary is not permitted."
}

After Testing , I found the script is detected as the number for the execution is incremented but the issue is created normally for an issue which have "test" in summary

Please advice 

Regards,

2 answers

0 votes
Michel saliba December 10, 2023

Hello Peter-Dave,

The exception is used now and the validator is now working

Thanks

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 10, 2023

You might find the "Simple Scripted Validator" simpler to use.

You just have to return a true or false to determine if the validation should pass or not.

But if you really want to keep the Custom Script Validator, you have to throw an exception in order to generate an error.

 

import com.opensymphony.workflow.InvalidInputException

def summary = issue.summary
// Check if the summary contains the string "test"
if (summary && summary.toLowerCase().contains("test")) {
// Issue creation is not allowed
throw new InvalidInputException("Issue creation with 'test' in the summary is not permitted.")
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events