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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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?

@Enkhtaivan Ganbat  Did the script work for you? 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Asked in Jira Service Desk

Calling all Insight users, we need your help!

Hello Insight users,  As part of our (Mindville's) acquisition by Atlassian, our training team is looking to build some new Insight training materials. It would really helpful if you can ...

52 views 0 0
View question

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you