Is there a way to change the content of a filter with a script ?

Laurent Bierge
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 8, 2018

Hi,

I've done a script that allow me to replace an issue type by an other one in all my Jira.

It works, but it breaks all the filter of the previous type.

Is there a way to change the content of all filter.

Like:

def filterMan = ComponentAccessor.filterManager()

def allFilters = filterMan.getAllFilters()

def jqlRequest

allFilters.each{

if ("issue Type" in it.getJqlRequest()){

jqlRequest = it.jqlRequest()

jqlRequest.replace("issue Type", "new issue Type")

it.setJqlRequest(jqlRequest)

}

}

My main issue consist in getting all the jql request of all the filter.

 

Regards,

Laurent

2 answers

1 accepted

1 vote
Answer accepted
Laurent Bierge
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 8, 2018

Hi,

While doing it with a script seems not possible, database request should do the trick:

https://community.atlassian.com/t5/Jira-questions/How-to-edit-multiple-filters-to-change-a-JQL-value/qaq-p/302271

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.
March 8, 2018

Remember to take Jira offline, back up the database, prove you can restore it first, otherwise you could lose the lot.

Never play with SQL without a backup and a clear understanding of what you are doing.

Please, do this with a script.

Laurent Bierge
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 8, 2018

Hi,

Thank you very much for your warning. I'll do as you say and make sure that i'm able to restore the database before making my modifications.

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.
February 9, 2018

What do you mean by change the content of a filter?  Are you trying to get different results, or update the ones you got from the current filter?

Laurent Bierge
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 12, 2018

Hi Nic,

Actually i want to change the jql request of the filter. To get to your point, i want a different result.

To sum up:

I'm on a french server, and instead of translate types, they created "English types" and "French types". Therefore we have things like type "Bug" and type "Bogue". (Bogue is the french translation for Bug)

I made a script that supress "Bogue" and replace it with "Bug". (i changed all the issue, update issue type screen,...)

It works but i didn't find a way to change filters.

Therefore, if a user had a filter like "project = MP and issuetype = 'Bogue'", it won't work anymore. The result will be empty.

I want to find a way to get through all filters that have "Bogue" in there Jql request and change those jql request by replacing "Bogue" with "Bug". So that my user will have "project = MP and issuetype = 'Bug'"

Any idea ?

Regards,

Laurent

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.
February 13, 2018

I'm sorry, this is the hard one to fix.  Filters don't (yet) use ids properly, they are plain text, so I'm afraid you have to go fix every one of them manually.

Normally, we're removing the target, so at least they give users an error when they need fixing.

Laurent Bierge
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 14, 2018

MMmmmm ok, i wanted to remove the target anyway.

Thank you very much for your answer :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events