I'm sorry, my programming skills are unfortunately not sufficient to connect these two snippets in a meaningful way. Therefore I would be glad about some help.
What is the goal? I have a number of tickets and want to dynamically determine the key with the highest number to use in further JQL queries/dashboards. I want to save this query as a filter.
The first script determines the key, the second saves it as a filter. But here I need a hint how to connect the two.
Many greetings
Alexander
Identifying the key
import ...
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchService = ComponentAccessor.getComponent(SearchService)
def jqlSearch = "project = ABC and type = story ORDER BY key DESC"
def query = jqlQueryParser.parseQuery(jqlSearch)
def results = searchService .search(user,query, PagerFilter.getUnlimitedFilter())
results.getResults().first()
Saving as filter
import ...
def searchRequestService = ComponentLocator.getComponent(SearchRequestService)
def user = ComponentAccessor.jiraAuthenticationContext?.getLoggedInUser()
def searchService = ComponentAccessor.getComponent(SearchService)
def serviceContext = new JiraServiceContextImpl(user)
THIS NEEDS TO BE REPLACED WITH THE RESULT ABOVE?
def parseResult = searchService.parseQuery(user, "project = JRA")
if (parseResult.isValid()) {
// create the search request
def query = parseResult.query
def searchRequest = new SearchRequest(query, user, "My filter", "Some description")
// set shares
def sharePerm = new SharePermissionImpl(null, ShareType.Name.GROUP, "jira-administrators", null)
searchRequest.setPermissions(new SharedEntity.SharePermissions([sharePerm] as Set))
// store the search request
searchRequestService.createFilter(serviceContext, searchRequest)
}
Hi @Alexander
If you intend to create a JQL Filter via ScriptRunner, you can refer to this ScriptRunner Documentation for more information.
It provides an example of how to do this via the ScriptRunner Console.
I hope this helps to answer your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.