Gemini Community Support Site

This Gemini community support site can be used to find solutions to product issues. You can log in using Open Id, Google Profile and even Facebook. Feel free to ask a question or browse FAQs and documentation. Product tour videos are also available along with how-to videos demonstrating key Gemini capabilities.




issueFilter - use custom fields in the filter

api

I have a basic working filter (code below), but would like to add a custom field to the filter (i.e. filtering by a particular value that is held in a custom field). Is this possible? IssuesFilterEN does appear to have access to CustomFields but I am not sure how to actually use a custom field.

            //create instance of the issue class
            IssuesService issueService = m_smProxyManager.IssuesService;
           
            IssuesFilterEN issueFilter = new IssuesFilterEN();
            //issueFilter.FilterID = 2;
            issueFilter.ProjectID = "1|3";
            issueFilter.CustomFields
            //issueFilter.SortOrder = GeminiConstant.SortDirection.Ascending;

            String summary = "Test";

            //int vFilterID = 2;
            IssueEN[] issueList = issueService.GetFilteredIssues(issueFilter);

            int c = issueList.Length;

Many thanks as always...!

martin
· 1
martin
Replies (5)
helpful
0
not helpful

It takes in a GenericEN array (at the moment with the maximum size of 1), the GenericKey is the custom field id, and the GenericValue is the values to look for (if it is a list as in this example):
List<GenericEN> customFieldsFilter = new List<GenericEN>();
customFieldsFilter.Add(new GenericEN() { GenericKey = "1", GenericValue = "1|2" });
issueFilter.CustomFields = customFieldsFilter.ToArray();


Mark Wing
· 9108
Mark Wing
helpful
0
not helpful

I think I must be missing something - the line below generates a whole load of errors (in the list at the bottom of the post) - is there something else I need to add/do? I have highlighted the errors in the code.

customFieldsFilter.Add(new GenericEN(){GenericKey = "1", GenericValue = "" });

) expected
; expected
Invalid experssion term ','
; expected
; expected
Invalid experssion term ')'


martin
· 1
martin
helpful
0
not helpful

It is .NET 3.5 syntax. Just create a new GenericEN set the properties and add it to the list:
GenericEN g = new GenericEN();
g.GenericKey= "1";
g.GenericValues = "1|2";
customFieldsFilter.Add(g);


Mark Wing
· 9108
Mark Wing
helpful
0
not helpful

Ahh, so the thing I was missing was .NET3.5!The second bit of code you gave worked nicely - a warning for others, when using IssuesFilterEN, make sure you set one or more project ID's otherwise the filter will return 0 values.Working code below:            //create instance of the issue class            IssuesService issueService = m_smProxyManager.IssuesService;                        IssuesFilterEN issueFilter = new IssuesFilterEN();            issueFilter.ProjectID = "3";            List<GenericEN> customFieldsFilter = new List<GenericEN>();            GenericEN g = new GenericEN();            g.GenericKey = "2";            g.GenericValue = "00042196";            customFieldsFilter.Add(g);            issueFilter.CustomFields = customFieldsFilter.ToArray();            String summary = "";            IssueEN[] issueList = issueService.GetFilteredIssues(issueFilter);            foreach (IssueEN issue in issueList)            {                summary = summary + issue.IssueSummary + ";";            }            int c = issueList.Length;


martin
· 1
martin
helpful
0
not helpful

Glad all is working now.
Many thanks for sharing your code.


Mark Wing
· 9108
Mark Wing