Create a max number of tickets scheduled on a date with scriptrunner

Flavie Henry March 28, 2024

Hello,

We would like to block the creation of more than x tickets at a date defined in the ticket which is a mandatory field when it is created.

We have create a validator on the transition “Create” with script runner.  However our code does not work, would you have any advice ? 

Here is the code we have on the validator :

import java.util.logging.Logger 
String projectUrl = get("/rest/api/2/issue/ITEST-59").asObject(Map).body['fields']['project']['self']
Logger logger = Logger.getLogger("")
http://logger.info (get(projectUrl).asObject(Map).body.name)

 
We are on Jira Cloud. 

Thank you for your help, 

2 answers

0 votes
Stephen Wright _Elabor8_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 29, 2024

Hi @Flavie Henry 

You can sort of do this natively using Automation. You can't block the creation, but you could notify a user after creation, and/or delete the issue.

This rule will...

  • Trigger if an issue is created
  • Lookup the issues based on a specific parameter in JQL
  • Compare if the size of the looked up issues is greater than N (eg. 29)
  • Take action based on the results of the comparison

---

For example...

  • Trigger: Issue created
  • Condition: Issue fields condition
    • Field = <field here>
    • Condition = is not empty
  • Action: Lookup Issues
    • JQL - project = ABC and "Date Picker" = <date here>
  • Condition: {{smart values}} condition
    • First value = {{lookupIssues.size}}
    • Condition = greater than
    • Second value = 29
  • Action...

---

A few notes...

  • You need to decide which Action is best for you, you could use...
    • Comment on issue - requesting user changes the date, etc
    • Delete issue - if you do this, I'd notify the creator using a "Send email" action
    • Edit Issue - use an Issue Security Scheme to restrict access to the issue (edit the security level)
    • Clone issue & Delete issue - clone the issue to another, hidden Project then delete it - this is a "soft delete" option
  • This is an example rule, you might need to tweak it to your specific needs

---

Let us know your thoughts!

Ste

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.
March 28, 2024

Hi Flavie,

I can confirm that ScriptRunner for Jira Cloud Workflow validators use the Jira Expression framework provided by Atlassian, and the Jira Expression Framework does not provide any way to use JQL in an expression.

This, unfortunately, means there will be no way in the validator to search for the number of issues created on a specific date and block the creation of the issues due to this.

I hope this information helps.

Regards,

Kristian

Suggest an answer

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

Atlassian Community Events