I have multiple users across my organization's enterprise that use the IssueFunction in linkedIssuesOf(Subquery, [link name]). We've updated our ScriptRunner version that now uses IssueFunction in linkedIssuesOfAll(Subquery, [link name]).
Is there a way that I can tell what filters in my organization use the old IssueFunction version and or better yet replace those with the new version?
This script works for me, but try this on a test instance first to make sure it works as expected for you. Additionally, you'll want to back up your production instance before trying this on there as well just to be sure everything can be recovered if things go south.
That being said, just pop this in the script console, and it should change all of the filters with linkedIssuesOf to linkedIssuesOfAll:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchRequest
import com.atlassian.jira.issue.search.SearchRequestEntity
import com.atlassian.jira.issue.search.SearchRequestManager
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.util.Visitor
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchRequestManager = ComponentAccessor.getComponent(SearchRequestManager)
def userManager = ComponentAccessor.getUserManager()
searchRequestManager.visitAll(new Visitor<SearchRequestEntity>() {
@Override
void visit(SearchRequestEntity searchRequestEntity) {
def requestString = searchRequestEntity.request
if (requestString.contains("linkedIssuesOf(")){
def newRequestString = requestString.replaceAll(~/\blinkedIssuesOf\b\(/, "linkedIssuesOfAll(")
def owner = userManager.getUserByName(searchRequestEntity.author)
def query = jqlQueryParser.parseQuery(newRequestString)
def name = searchRequestEntity.name
def description = searchRequestEntity.description
def newRequest = new SearchRequest(query, owner, name, description, searchRequestEntity.id, searchRequestEntity.favCount)
searchRequestManager.update(newRequest)
}
}
})
Sorry this took me a while, let me know if you have any questions!
Even if you're a system admin in Jira, you won't be able to see all the filters created by all users. Only if that user shares the filter with you, can you even see it.
If you're using Jira Server, I think one way to help identify this would be to go to the SQL database for Jira and then use a SQL query to find these filters. You could do this with a statement such as:
select * from searchrequest where reqcontent like '%linkedIssuesOf%';
on a postgresql database. The syntax might be slightly different for other database types. But this would at least help tell you which filters in your Jira instance are using this specific term.
It might be technically possible for you to update these directly via SQL, but I wouldn't recommend making changes to the SQL database directly. Especially while Jira is running. It would be safer to make these changes in the Jira web interface one by one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, I'm hesitant to do direct DB edits as well. Appreciate the alternative. And the fact that we only have ~140 needing edits (and some aren't used anymore) makes me more comfortable.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.