Hi All,
Please guide me is there any option is available to auto capture the number issues (just count) in a saved issue filter to a custom field as part of workflow post-function?
Thanks in advance.
Community moderators have prevented the ability to post new answers.
you can try with following code but you need to add imports and little bit modifications
String jqlSearch = "filter= \"" + filterName + "\""; SearchService searchService = ComponentAccessor.getComponentOfType(SearchService.class); ParseResult parseResult = searchService.parseQuery(authenticationContext.getLoggedInUser(), jqlSearch); int totalIssues = 0; if (parseResult.isValid()) { try { SearchResults results = searchService.search(authenticationContext.getLoggedInUser(), parseResult.getQuery(), PagerFilter .getUnlimitedFilter()); final List<Issue> issues = results.getIssues(); totalIssues = issues.size(); //add code here to update custom field } catch (SearchException e) { e.printStackTrace(); } }
Hi Rambanam,
Thanks for sharing this.
I'm very much new to this programming. If possible could you please share how I can go ahead with this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is this below code will work?
<script type="text/javascript">
String jqlSearch = "filter= \"" + demo + "\"";
SearchService searchService = ComponentAccessor.getComponentOfType(SearchService.class);
ParseResult parseResult = searchService.parseQuery(authenticationContext.getLoggedInUser(), jqlSearch);
int totalIssues = 0;
if (parseResult.isValid()) {
try {
SearchResults results = searchService.search(authenticationContext.getLoggedInUser(), parseResult.getQuery(), PagerFilter
.getUnlimitedFilter());
final List<Issue> issues = results.getIssues();
totalIssues = issues.size();
//add code here to update custom field
FormField category = getFieldById("customfield_10319")
category.setFormValue("totalIssues")
} catch (SearchException e) {
e.printStackTrace();
}
}
</script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hey! this is not javascript,
you have to try this code with script runner plugin, check this
https://jamieechlin.atlassian.net/wiki/display/GRV/Post+Functions
or develop post function using javasyntax, check this to know how to develop postfunction
http://www.j-tricks.com/1/post/2010/08/workflow-post-function.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ah, is it a groovy script? could you please share me with this code how I can add a value (totalIssues) to a custom field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using the Script Runner plugin, you could write a post function script which would perform the following steps:
1. Use the JqlQueryBuilder to generate a query (The same query that's in your filter)
2. Use the SearchResults object to get the results of the query.
3. Get the count of the number of issues in the SearchResults list.
4. Store the number in a custom field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any suggestions guys?
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.