Deleted Filter in JIRA, how can I restore the filters?

Siva Prasad Swain April 7, 2018

Seem to have deleted filter by mistake and am now unable to see the related boards.

Please advise as to what to do?

I have the JIRA Admin access.

 

Thanks.

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 7, 2018

Create a new filter with the same name and definition, then edit each board to replace the deleted one.

Jira Cloud Donweb November 17, 2021

Same problem, this does not work.

Jira Server does not show the board so it is not possible to edit it.

Is there a workaround to actually edit the board and replace the filter?

Brian Swackhamer April 11, 2022

you have to go to the database to find the board or using scriptrunner.

 

This finds the boards with no filterID --- if you update fix = True it will delete them.  This code was taken off a search I did elsewhere.

def fix = false //if set to true this will delete the boards that have no filter associated

import com.atlassian.greenhopper.model.rapid.RapidView
import com.atlassian.greenhopper.manager.rapidview.RapidViewManager
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.issue.search.SearchRequestManager
import com.atlassian.jira.component.ComponentAccessor

public class NoCheck implements RapidViewManager.RapidViewPermissionCheck
{
public boolean check(RapidView view)
{
return true;
}
}
@WithPlugin("com.pyxis.greenhopper.jira")
@JiraAgileBean
RapidViewManager rapidViewManager
SearchRequestManager srm = ComponentAccessor.getComponent(SearchRequestManager)

def removed = []
rapidViewManager.getAll(new NoCheck()).value.each {b->
if(srm.getSearchRequestById(b.savedFilterId)==null) {
if(fix) {
def res = rapidViewManager.delete(b)
}
removed.add("${b.id} ,${b.name} ,${b.owner} || ")
}
}
def result = removed.join("\n")
return result

 

Then if you know the board (rapidviewID) and create a new filter then this script will update the board and allow you to see it.

 
import com.atlassian.greenhopper.manager.rapidview.RapidViewManager
import com.atlassian.greenhopper.model.rapid.RapidView
import com.onresolve.scriptrunner.runner.customisers.PluginModuleCompilationCustomiser
import com.atlassian.jira.component.ComponentAccessor

long BOARD_ID = 296 //change to the rapidview id
long FILTER_Id = 79382 //new filter for that board

def rapidViewManager = PluginModuleCompilationCustomiser.getGreenHopperBean(RapidViewManager)
def rapidView = rapidViewManager.get(BOARD_ID).get()

rapidViewManager.update(new RapidView.RapidViewBuilder(rapidView).savedFilterId(FILTER_Id).build())
Mary Joycelyn Bunag October 3, 2022

The code works, @Brian Swackhamer Thank you!

Like Brian Swackhamer likes this

Suggest an answer

Log in or Sign up to answer