简体   繁体   English

Redmine Java API:根据customField值获取问题

[英]Redmine Java API: get Issues based on customField value

I am trying to fetch issues based on customField Value. 我试图获取基于customField值的问题。
Tried following but no luck so far. 尝试过但到目前为止没有运气。 Please help. 请帮忙。

Params params = new Params();  

/* Getting params from map*/ / *从地图获取参数* /

for (Map.Entry<String, String> mapEntry : paramMap.entrySet()) {  
          params.add(mapEntry.getKey(), mapEntry.getValue());  
}
    ResultsWrapper<Issue> sqLst;

//1. // 1。 Didn't work 没工作

CustomField customField = CustomFieldFactory.create(cfIdBusinessOwner, "Business Owner", "");  
        customField.setValue("ABC");  
        params.add("custom_fields", customField); 

//2. // 2。 Didn't work 没工作

 params.add("custom_field[" + cfIdBusinessOwner + "]", "abc");

//3. // 3。 Didn't work 没工作

 params.add("cf[" + cfIdBusinessOwner + "]", "abc");

//Continuous Code //连续代码

params.add("status_id", "*");  
    issueLst= issueManager.getIssues(params);

After spending a lot of time on the internet finally, I could figure out how to. 终于在互联网上花了很多时间之后,我才知道该怎么做。 and it is really simple and straightforward. 这真的很简单明了。

params.add("cf_X", "Value");

where X is the id of CustomField and Value is what you want to look for. X是CustomField的ID, Value是您要查找的。

I am still trying to figure out how to look for part of the value for given field like we do in SQL like operator '%XYZ%' . 我仍在尝试找出如何为给定字段查找值的一部分,就像我们在SQL中一样,例如运算符'%XYZ%'

Please help me if someone already has some clue on that. 如果有人已经对此有所帮助,请帮助我。

UPDATE UPDATE

Found the answer to my second query in the answer above about search with like operator: 在上述关于使用like运算符进行搜索的答案中找到了我第二个查询的答案:
Solution: 解:

paramMap.put("set_filter","1");`
paramMap.put("f[]","cf_X");
paramMap.put("op[cf_X]","~");
paramMap.put("v[cf_X][]","PartOfValue");

Where X is the custom field ID and PartOfValue is what you want to search is given field 其中X是自定义字段ID, PartOfValue是要搜索的字段

params.add("cf_X", "Value");

where X is the id of a CustomField and Value is what you want to look for. XCustomField的ID, Value是您要查找的内容。

Work for me. 为我工作。 Also, remember that a Custom field must have 'used as a filter' checked. 另外,请记住,必须选中“自定义”字段“用作过滤器”。

While the answers are correct here. 虽然答案是正确的。 This option will work only when the project_id is used along side the cf_X filter 仅当在cf_X过滤器旁边使用project_id时,此选项才有效

For Eg: http://redmine.com/issues.xml?project_id=projectName&cf_77=Transition 例如: http: //redmine.com/issues.xml?project_id=projectName&cf_77= 过渡

Else this will continue to return all the issues without filtering 否则,它将继续返回所有问题而不进行过滤

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM