I am having trouble sorting a result set by a field using the ClearQuest Api in C#. I was trying to follow this tutorial but it seems like the methods are not the same in the C# ClearQuest Api. If someone could post an example of how to sort a data set ascending by a field name that would be great!
Edit: Here's a code example that I have tried:
Session cqSession = new Session();
cqSession.UserLogon("exampleuser", "examplepassword", "exampledb", 2, "ex_db_set");
OAdQuerydef queryDef = (cqSession.BuildQuery("Defect")) as OAdQuerydef;
// build fields of result set
queryDef.BuildField("id");
queryDef.BuildField("state");
queryDef.BuildField("headline");
queryDef.BuildField("total_est_hrs");
// Create filter operators
IOAdQueryFilterNode filter1 = queryDef.BuildFilterOperator(AND);
IOAdQueryFilterNode filter2 = filter1.BuildFilterOperator(AND);
IOAdQueryFilterNode filter3 = filter2.BuildFilterOperator(AND);
// build filters
filter1.BuildFilter("state", EQUAL, "Opened");
filter2.BuildFilter("id", GREATER_THAN, "SCR00032251");
filter2.BuildFilter("id", LESS_THAN, "SCR00139300");
filter3.BuildFilter("total_est_hrs", GREATER_THAN, "0");
// Here is where I am having a tough time sorting the id field.
// I just want the id field to be sorted in order ascending from least to greatest
IOAdQueryFieldDef queryFieldDef = queryDef.QueryFieldDefs("id");
queryFieldDef.SetSortType(AD_SORT_ASC);
OAdResultset rs = (cqSession.BuildResultSet(queryDef)) as OAdResultset;
rs.ExecuteAndCountRecords();