Is it possible to set a limit for the number of requests an customers can raise?

Enkhtaivan Ganbat August 23, 2018

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?

1 answer

1 accepted

3 votes
Answer accepted
Dave Bosman _Realdolmen_
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.
August 23, 2018

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

Enkhtaivan Ganbat August 23, 2018

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?

Chaitanya Srinadhu November 6, 2019

@Enkhtaivan Ganbat  Did the script work for you? 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events