Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Our customers are companies and are divided into platinum, gold and silver customers, we need to set different limits for the total number of requests they can raise in a given time frame, depending on whether they are platinum, gold or a silver customer. Is it possible at all?
Hi,
You would be able to that with Scriptrunner
In the workflow validators you can write a script where you can check the amount of issues (with a jql) created during a certain period.
I found following script somewhere a while ago and modified it a little for our own purpose.
But i think it would be usefull in your case to.
2 things you will need to modify: The JQL used and the warning message ;-)
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.bc.JiraServiceContextImpl;
import com.atlassian.jira.bc.filter.SearchRequestService;
import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.search.SearchResults;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.web.bean.PagerFilter;
import com.atlassian.query.Query;
import com.opensymphony.workflow.InvalidInputException
SearchResults getIssuesByJQL(String jql) throws Exception
{
SearchService serchService = ComponentAccessor.getComponentOfType(SearchService.class);
SearchService.ParseResult parseResult =
serchService.parseQuery(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(),
jql);
if (!parseResult.isValid())
{
throw new Exception("jql is not valid. jql was "+jql);
}
Query query = parseResult.getQuery();
SearchResults sr =
serchService.search(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(),
query, PagerFilter.getUnlimitedFilter());
return sr;
}
def coinValue
coinValue = getIssuesByJQL("project = TCP AND reporter in (currentUser()) AND created >= endOfMonth(-1)").getTotal()
if (coinValue > 4) {
invalidInputException = new InvalidInputException("U heeft de limiet van 5 coins bereikt deze maand.")
}
Reagrds
Dave
Hi Dave,
Thank you for the script!, I'll try to modify it to suit our needs. This script seems to be written in Java, is there a JAVA API?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.