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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,455,373
Community Members
 
Community Events
175
Community Groups

How to use JQL querys in a scheduled service??

I am programming a service within a plugin. It is a service that is programmed in the administration for automatic execution. I need to do JQL queries from it, but 0 records are always retrieved.
If the same query is executed within another action, it does return results. From the service, the AO query and the retrieval of data from objects such as the issue, the project, the history, ... work well, but not the JQL queries.
Any idea to be able to carry out that query from here?

public class UpdateDaysInsStatusService extends AbstractService{

@Override
public ObjectConfiguration getObjectConfiguration() throws ObjectConfigurationException {
return getObjectConfiguration("UpdateDays", "services/updateDays.xml", null);
}

@Override
public void run() {
pruebajql("Backlog");
}

private void pruebajql (String estado) {
SearchService searchService = ComponentAccessor.getComponent(SearchService.class);
JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
builder.where().project("TKB").and().status(estado);

Query query = builder.buildQuery();
SearchResults<Issue> results;

try {
results = searchService.search(user, query, PagerFilter.getUnlimitedFilter());
System.out.println(" filas encontradas: " + results.getResults().size());

} catch (SearchException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}

 

1 answer

0 votes
Clark Everson Community Leader Oct 31, 2021

Hi Pablo,

Welcome to community!

I believe when working with this part of Jira you want to use SQL not JQL. JQL is for the graphical interface, not scripting, the database or the API.

Best,

Clark

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events