Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Limit Number Of Issues Customer Can Open Script Runner

Austin Cody
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!
February 5, 2024

I'm currently using the following scriptrunner code in my post creation transition validator, but it's throwing an error. 

Code - 

reporter = issue.reporter jql = "project = PE and resolution = Unresolved and reporter = currentUser()" jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser) searchService = ComponentAccessor.getComponent(SearchService) query = jqlQueryParser.parseQuery(jql) count = searchService.searchCount(reporter, query) if (count >= 2) { throw new InvalidInputException("The limit of open tickets for the 'PE' project is reached for the current user") }

 Error -  ScriptRunner Script. The configuration is invalid.

 

The goal is to limit current users from not being able to open more than two tickets at a time. 

2 answers

0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 7, 2024

Hi Austin,

I can confirm that inside of Jira Cloud Workflow Validators use the Jira Expression Framework provided by Atlassian.

You must use the Jira Expression Framework syntax to write your validator. We have many examples here that show how to write validator expressions to help you write the validator you require.

I hope this information helps.

Regards,

Kristian

0 votes
Jeroen Poismans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 5, 2024

Hi and Welcome to the Atlassian Community!

You can not use this code on Cloud. Services like ComponentAccessor, JqlQueryParser ... etc you can't access them in Cloud. You will have to rewrite your Server / Datacenter code to a Cloud compatible version using the Cloud REST API's.

Have a look at this resource from Adaptavist explaining this:

https://docs.adaptavist.com/sr4jc/latest/differences-between-scriptrunner-for-jira-server-and-jira-cloud/platform-differences

Jeroen

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events