Hello,
There is the task to modify monthly the filter like "issuetype = Bug AND created >= 2022-10-20", that is instead of 10 some variable should be used.
To schedule the update, I'm going to use the Jira Automation.
Appreciate any help.
BR,
Ivan
Hi @Ivan D
Why don't you use scriptrunner's Jobs?
I can help with a groovy script to modify a filter.
But I'm not sure this business case necessarily requires it.
If for example, you're interested in all issues created in the previous month you can use strict JQL with relative date functions:
created > StartOfMonth(-1) and created < EndOfMonth(-1)
Right now, this shows all issues created in August. On October 1 it will start to show all issues created in the month of September
If you need "exactly" issues created after the 20th of the month... that won't work. But you could have issues created since 10days before the start of the month (that will be after 20th or 21st)
created > StartOfMonth(-10d)
Hi Alex,
It's not essential how to schedule the execution. I'm more familiar with the automation and it has such action as running groovy scripts.
The main concern for me is the script.
Here is a short script to retrieve and update a filter:
import com.atlassian.jira.bc.issue.search.SearchServiceimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.search.SearchRequestManagerdef searchRequestManager = ComponentAccessor.getComponent(SearchRequestManager)def searchService = ComponentAccessor.getComponent(SearchService)def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUserdef filterId = 123456Ldef monthVariable = 10def filter = searchRequestManager.getSearchRequestById(filterId)def jql = """issuetype = Bug AND created >= 2022-$monthVariable-20"""def parseResult = searchService.parseQuery(currentUser, jql)assert parseResult.valid: parseResult.errorsfilter.query = parseResult.querysearchRequestManager.update(currentUser, filter)
User executing the script must have permissions to edit the filter.
Hi Peter-Dave,
I see your doubt and share it - yes, it's not a big deal once a month to change a filter just manually. Maybe because of it I haven't found any examples of this kind to start from. But they want some automation.
Regarding the query, it makes sense in format like created >= 2022-XX-20, as they need tickets since some date till a date when they require it. It's not always the end of a month.
Thanks a lot, Peter-Dave.
I'll try it. Probably instead of monthVariable = 10 anything like now.getMonth() to be used, as the script will run by schedule?
It looks like you're new here. Sign in or register to get started.