Hi,
I am trying to edit several hundreds of Kanban Board quick filters to reflect changed values.
I am using the below code and get until I can actually update the filter. However, the update is failing with a NullPointerException for some reason. I have already checked all of the passed in parameters to this function and they all have values unequal to null.
I am using ScriptRunner console to run this. Imports have been done correctly
Can you please help?
Thanks!
import com.atlassian.greenhopper.model.rapid.QuickFilter
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.rapid.view.QuickFilterService
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.atlassian.greenhopper.model.rapid.QuickFilter.QuickFilterBuilder
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.greenhopper.model.validation.*
import com.atlassian.greenhopper.web.rapid.view.RapidViewHelper
import com.atlassian.greenhopper.service.rapid.view.QuickFilterServiceImpl
@WithPlugin("com.pyxis.greenhopper.jira")
@JiraAgileBean
RapidViewService rapidViewService
@JiraAgileBean
QuickFilterService quickFilterService
@JiraAgileBean
RapidViewHelper rapidViewHelper
def authenticationContext = ComponentAccessor.jiraAuthenticationContext
def applicationUserInput = authenticationContext.loggedInUser
QuickFilterServiceImpl quickFilterServiceImpl = new QuickFilterServiceImpl()
def errorCollection = new ErrorCollection()
if(rapidViewService) {
def rapidViews = rapidViewService.getRapidViews(applicationUserInput).value
rapidViews.each {
List<QuickFilter> rapidViewsIn = quickFilterService.loadQuickFilters(it).each{qf ->
//Just some arbitrary change to change a default filter
String newQuery = qf.query.replaceAll("-1d", "+2d").toString()
def qfBuilder = new QuickFilterBuilder()
QuickFilter newQf = qfBuilder.query(newQuery).description(qf.description).name(qf.name).id(qf.id).position(qf.position).build()
def update = quickFilterServiceImpl.update(applicationUserInput, it, newQf, errorCollection)
}
}
}