Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JQL and concatenation

Nico van Leeuwen February 24, 2013

Hi,

Does anyone know if or how it is possible to use concatenations in JQL?

example: text ~ "Fixed Text".currentUser()."Fixed Text"

I have not been able to find any reference to concatenations in any documentation anywhere and have not seen any similar questions. So it seems like it is simply not possible. Would of course be great if I am wrong about this.

Thanks.

2 answers

0 votes
MB
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.
September 29, 2013

Hi :)

The usual way to build your JQL query is to use JqlClauseBuilder like this:

JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();
JqlClauseBuilder jqlClauseBuilder = builder.where().project("TP").and().reporterUser("admin").or().reporterUser("test");

//now perform the actual search (only interested in number of results)
searchService.searchCount(user, builder.buildQuery());
//or if you need the standard result set
searchService.search(user, builder.buildQuery(), PagerFilter.getUnlimitedFilter());

More info in this article.

That way you can build most of your queries. Sometimes, when you need to add a custom query string, to create a more advanced query, you need to "concatenate" the additional string (in a WHERE clause) to your already created jql, which can be accomplished like this

JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();
JqlClauseBuilder jqlClauseBuilder = builder.where().project("TP").and().reporterUser("admin").or().reporterUser("test");

String finalQueryString = builder.buildQuery().getWhereClause().toString();
finalQueryString += " AND ( project = TP )"; // this is where you concatenate your custom jql string

SearchService searchService = ComponentAccessor.getComponent(SearchService.class);
if (searchService != null)
	try {
		finalQueryString = finalQueryString.replace("{", "(").replace("}", ")"); // replace special chars...
		SearchService.ParseResult parseResult =  searchService.parseQuery(user, finalQueryString);
		if (parseResult.isValid()) {
			searchService.searchCount(user, parseResult.getQuery());
			...
		} else {
			// jql is not valid
		}
	} catch (SearchException e) {
		// an error occurred while performing the search
	}
}

I hope it helps.

0 votes
Shaikh Moiz
Contributor
February 24, 2013
Piotr Boho
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!
October 9, 2020

This is solution with API. the question was about JQL in UI

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, team '25 europe, atlassian event, barcelona 2025, jira, confluence, atlassian intelligence, rovo, ai-powered collaboration, developer tools, agile teams, digital transformation, teamwork solutions, atlassian conference, product announcements

🌆 Team '25 Europe registration is now open!

Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.

Register now
AUG Leaders

Atlassian Community Events