Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Need groovy script to update the filters

Meghana K V
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Sep 27, 2023

Need groovy script to run from Jira script runner to update the filters:

Fetch all the JQL filters based on issue type which is equal to "xyz",

then exclude the ones with issue type "Profile xyz", then update the filters with issue type as "feature".

1 answer

1 vote
Ram Kumar Aravindakshan _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.
Sep 29, 2023

Hi @Meghana K V

Could you provide a little bit more information, i.e. what Automation function are you using for this? Is the Issue Create or Transition Issue? 

It would be beneficial if you could share a screenshot of your Automation configuration.

I am requesting this so I can provide a sample script.

Thank you and Kind regards,


Meghana K V
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Oct 02, 2023

Hi @Ram Kumar Aravindakshan _Adaptavist_ ,

Thank you for your reply.

I have created the following script for the requirement mentioned above, but it's not working, please let me know what I am missing.

I have to fetch all the filters with issuetype = EPIC and exclude the ones with issuetype = Portfolio EPIC and then to the resulting filters, I need to change the issuetype to Feature.

import com.atlassian.jira.user.ApplicationUser

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.bc.filter.SearchRequestService





import com.atlassian.jira.bc.JiraServiceContextImpl

import java.lang.StringBuffer


SearchRequestService searchRequestService = ComponentAccessor.getComponent(SearchRequestService.class)

UserSearchService userSearchService = ComponentAccessor.getComponent(UserSearchService)

SearchService searchService = ComponentAccessor.getComponent(SearchService)

def sb = new StringBuffer()

def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def ctx = new JiraServiceContextImpl(loggedInUser)


UserSearchParams userSearchParams = new UserSearchParams.Builder()







// Define the issue type name to search for

def issueTypeName = "EPIC"

def excludedIssueTypeName = "Portfolio EPIC" // Add the excluded issue type name here

def newissueTypeName = "Feature"

 println "Starting script execution"

// Iterate over each user's filters

userSearchService.findUsers("", userSearchParams).each { ApplicationUser filter_owner ->

    try {

        searchRequestService.getOwnedFilters(filter_owner).each { SearchRequest ->

            def query = SearchRequest.query


            def queryString = searchService.getJqlString(query)

            println("Old Filter '$queryString' updated successfully.")


            if (queryString.contains(issueTypeName) && !queryString.contains(excludedIssueTypeName)) {


            String newQueryString = queryString.replace(issueTypeName, newissueTypeName)


            def newQuery = searchService.parseQuery(filter_owner, newQueryString).query

            sb.append("Filter for ${filter_owner.displayName}: ${}, ${query.getPermissions().isPrivate() ? 'Private' : 'Shared'}\n")



            searchRequestService.updateFilter(ctx, SearchRequest)



    }catch (Exception e) {

        // If filter is private or encounters an error

        sb.append("Unable to get filters for ${filter_owner.displayName} due to ${e}\n")




// Output results

return sb.toString()

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events