Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get issues list filtered by custom field #331

Open
napless opened this issue Sep 26, 2019 · 4 comments
Open

Get issues list filtered by custom field #331

napless opened this issue Sep 26, 2019 · 4 comments

Comments

@napless
Copy link

napless commented Sep 26, 2019

Hi, i need to get a list of all issue opened filtered by a custom field (id 17) that contain a date (ex. 2019-09-26).
How i can create this?
I've tried with this code, but the filter doesn't work.

`IssueManager issueManager = mgr.getIssueManager();
ResultsWrapper issues = null;

    Params params = new Params()
            .add("set_filter", "1")
            .add("f[]", "project_id")
            
            .add("v[project_id]", projectKey)
            .add("f[]", "cf_17")
            .add("op[cf_17]", "~")
            .add("v[cf_17]", "2019-09-26");
    try {
		issues = issueManager.getIssues(params);
		List<Issue> iss = issues.getResults();
		
		System.out.println(iss);
	} catch (RedmineException e1) {
		e1.printStackTrace();
	}
@alexeyOnGitHub
Copy link
Member

have you tried the corresponding request via curl, outside of the library? please check if this works first. if this works via curl but does not work in the library, feel free to provide a PR with a fix, please specify your Redmine version in this case since this may be version-specific

@napless
Copy link
Author

napless commented Jan 2, 2020

Hi Alexey.
with this curl, i get the issues that i want to retrieve.

http://redminefqdn/issues.xml?project_id=29&status_id=*&cf_17=2019-12-11

I think that the problem is in the "params" variable... could you help me to make right filter params variable?

Thank you in advance!

@napless
Copy link
Author

napless commented Jan 2, 2020

yeeeahh.. sorry for double post, but with this code, i've get the list of issues based on filter applied on custom field 17. :)

Only problem is that my custom field is a string, but contain a date, and i cannot apply the ">" "<" operator. Could you confirm that this isn't possible?

Params params = new Params()
.add("cf_17", "2019-12-11")
.add("project_id", "29")
.add("status_id", "*");

Thank you so much!

@alexeyOnGitHub
Copy link
Member

you can explore Redmine search params by constructing any query with ">=" and similar operands, e.g.
https://www.redmine.org/projects/redmine/issues?utf8=%E2%9C%93&set_filter=1&f%5B%5D=status_id&op%5Bstatus_id%5D=o&f%5B%5D=created_on&op%5Bcreated_on%5D=%3E%3D&v%5Bcreated_on%5D%5B%5D=2020-01-01&f%5B%5D=&c%5B%5D=tracker&c%5B%5D=status&c%5B%5D=subject&c%5B%5D=updated_on&c%5B%5D=category&group_by=

then apply the same parameters when calling Redmine using the library. the library simply forwards your params to the server, so whatever your server accepts in the URL should work in the library. with a possible exception when REST calls do not support some operations, which may happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants