ClearQuest Api not Sorting with Specific Fields

231 views Asked by At

For some reason when I try to sort by any field that isn't "total_est_hrs", or "id", I get a null referenced exception. This is the code I am using to get queries:

Session cqSession = new Session();
cqSession.UserLogon("user", "password", "db", 2, "set");
IOAdQueryDef queryDef = (cqSession.BuildQuery("Defect"));

queryDef.BuildField("id");
queryDef.BuildField("total_est_hrs");
queryDef.BuildField("severity");

IOAdQueryFieldDefs fieldDefs = queryDef.QueryFieldDefs;

IOAdQueryFieldDef sortField = fieldDefs.item("severity");
sortField.SortType = 1;
sortField.SortOrder = 1;

IOAdQueryFilterNode rootNode = queryDef.BuildFilterOperator(AND);
rootNode.BuildFilter("submit_date", GREATER_THAN, "1/1/2014");

OAdResultset rs = (cqSession.BuildResultSet(queryDef));
rs.ExecuteAndCountRecords();

The error says there is a null reference exception on line 9, where I am attempting to set the SortType. The GREATER_THAN and AND constants refer to the sorting and comparison constants found on the ClearQuest Api refefence.

If someone could explain what is going on, that would be great.

0

There are 0 answers