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.




API: GetIsssues using CustomFields

web-app

I'm trying to get all the issues that have a non-null value for a CustomField: Iteration. I've created a filter but I don't see a way to set a filtering value for a particular type of CustomField.

        List<ProjectEN> projects = WsManager.ProjectsService.GetProjects().ToList<ProjectEN>();

        string projectIds = projects.Aggregate<ProjectEN,string>(string.Empty,(list, p) => list + p.ProjectID.ToString() + "|");

        IssuesFilterEN filter = new IssuesFilterEN();
        filter.ProjectID = projectIds;
        filter.ExcludeClosed = false;

        filter.

        List<IssueEN> unfilteredIssues = new List<IssueEN>();

        unfilteredIssues = WsManager.IssuesService.GetFilteredIssues(filter).ToList<IssueEN>();
IMHobbes
· 1
IMHobbes
Replies (5)
helpful
0
not helpful

Please See: http://community.countersoft.com/forums/thread/13416.aspx

Howeevr, you can't filter for a not equals (or not null).


Saar Cohen
· 5000
Saar Cohen
helpful
0
not helpful

I've been able to filter by the customField, but now my entities only contain those customFields (as well as the rest of the issue data). I need some way to filter by one custom field while still getting all the return data for the other custom fields.

        List<ProjectEN> projects = WsManager.ProjectsService.GetProjects().ToList<ProjectEN>();

        ///
        /// Get all the project id's
        /// 
        string projectIds = projects.Aggregate<ProjectEN, string>(string.Empty, (list, p) => list + p.ProjectID.ToString() + "|");

        IssuesFilterEN filter = new IssuesFilterEN();
        filter.ProjectID = projectIds;
        filter.ExcludeClosed = false;

        ///
        /// Create a filter to collect only those issues that have an Iteration Custom Field
        /// 
        GenericEN iterationFilter = new GenericEN();
        iterationFilter.GenericKey = IterationField.CustomFieldID.ToString();
        iterationFilter.GenericValue = LatestIteration.Value.ToString();
        GenericEN[] customFieldsFilter = new GenericEN[1];
        customFieldsFilter[0] = iterationFilter;

        filter.CustomFields = customFieldsFilter;

        List<IssueEN> unfilteredIssues = new List<IssueEN>();

        ///
        /// loop through the number of iterations collecting the issues from each iteration and adding them to the list
        /// 
        for (int i = 1; i <= LatestIteration; i++)
        {
            filter.CustomFields[0].GenericValue = i.ToString();
            unfilteredIssues.AddRange(WsManager.IssuesService.GetFilteredIssues(filter).ToList<IssueEN>());
        }

IMHobbes
· 1
IMHobbes
helpful
0
not helpful

Unfortunately, you will have to execute the another non-customfield filter.

Basically, pass in the issue ids (pipe delimited) to the filter.


Saar Cohen
· 5000
Saar Cohen
helpful
0
not helpful

Alright, I've done something that works that I think is taking your advice. i have to say that it is cumbersome in the extreme. What I really want is a filter where i can find all the issues where the custom field exists, but where the value is not null. Then it should return the complete entities that match. Also, what is the reasoning behind explicitly having to identify the projects from which to choose the issues. Wouldn't it make sense that an empty project filter simply wouldn't filter out any issue by project? If a project is specified then it would only choose that project.

Anyway, here's my code. if you see anything that can be done to improve the performance, i'm all ears.

        List<ProjectEN> projects = WsManager.ProjectsService.GetProjects().ToList<ProjectEN>();

        ///
        /// Get all the project id's
        /// 
        string projectIds = projects.Aggregate<ProjectEN, string>(string.Empty, (list, p) => list + p.ProjectID.ToString() + "|");

        IssuesFilterEN filter = new IssuesFilterEN();
        filter.ProjectID = projectIds;
        filter.ExcludeClosed = false;

        ///
        /// Create a filter to collect only those issues that have an Iteration Custom Field
        /// 
        GenericEN iterationFilter = new GenericEN();
        iterationFilter.GenericKey = IterationField.CustomFieldID.ToString();
        iterationFilter.GenericValue = LatestIteration.Value.ToString();
        GenericEN[] customFieldsFilter = new GenericEN[1];
        customFieldsFilter[0] = iterationFilter;

        filter.CustomFields = customFieldsFilter;

        List<IssueEN> unfilteredIssues = new List<IssueEN>();

        ///
        /// loop through the number of iterations collecting the issues from each iteration and adding them to the list
        /// 
        for (int i = 1; i <= LatestIteration; i++)
        {
            filter.CustomFields[0].GenericValue = i.ToString();
            unfilteredIssues.AddRange(WsManager.IssuesService.GetFilteredIssues(filter).ToList<IssueEN>());
        }
        ///
        /// concatenate a list of issue ids
        /// 
        string issueIds = unfilteredIssues.Aggregate<IssueEN, string>(string.Empty, (list, i) => list + i.IssueID.ToString() + "|");

        ///
        /// remove the partial issues
        /// 
        unfilteredIssues.Clear();

        ///
        /// remove the custom field filter and filter for the activities
        /// 
        filter.CustomFields = null;
        filter.IssueID = issueIds;
        unfilteredIssues = WsManager.IssuesService.GetFilteredIssues(filter).ToList<IssueEN>();

IMHobbes
· 1
IMHobbes
helpful
0
not helpful

If you use GetPagedFilteredIssues to get the issues you will get all custom fields, removing the need to re-filter on issue ids.


Mark Wing
· 9108
Mark Wing