Need a list of all filters which uses a particular custom field

Ram August 4, 2023

Hi All,

 

I have been trying to execute the below script but its not yielding any result, can anyone please advise?

 

Hi All,

I trying the same script, but its not yielding any result, can you please help?

import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchRequestEntity
import com.atlassian.jira.issue.search.SearchRequestManager
import com.atlassian.jira.util.Visitor

def filtersWithField = []
def myCustomFieldRegex = ~/(.Mobile OS.)|(.cf\[10801\].)/
def searchService = ComponentAccessor.getComponent(SearchService)
def searchRequestManager = ComponentAccessor.getComponent(SearchRequestManager)
searchRequestManager.visitAll(new Visitor<SearchRequestEntity>() {
@Override
void visit(SearchRequestEntity filter) {
def jql = filter.request
if (jql.findAll(myCustomFieldRegex)) {
filtersWithField << searchRequestManager.getSearchRequestById(filter.id)
}
}
})
log.warn filtersWithField

1 answer

1 vote
Avinash Bhagawati {Appfire}
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 4, 2023

Hi @Ram ,

Welcome to the community!

If you would like to achieve this use case with ACLI ( https://marketplace.atlassian.com/apps/6398/jira-command-line-interface-cli?hosting=cloud&tab=overview ) which will be able to get the filters associated with specific custom fields.

 --action getFilterList --columns 1,4,9 --outputType table --select "9:Closed Date/Time"

Please refer sample screenshot for reference.

final-02.png

https://appfire.atlassian.net/wiki/spaces/JCLI/overview

Thanks
Avinash

Suggest an answer

Log in or Sign up to answer