I have been searching for a while and could not find a single example...
Using C# and Clearquest API I would like to do something as simple as running a query (for example get a list of CR's by owner)
How do I programatically create a CQ query?
I have been searching for a while and could not find a single example...
Using C# and Clearquest API I would like to do something as simple as running a query (for example get a list of CR's by owner)
How do I programatically create a CQ query?
Taken from http://www.ibm.com/developerworks/forums/thread.jspa?threadID=78133
SessionClass cqSession = new SessionClass();
cqSession.UserLogon("user", "pass", "dbname", 2,
"");
OAdQuerydef queryDef = (OAdQuerydef)
cqSession.BuildQuery("Issue");
queryDef.BuildField("id");
queryDef.BuildField("summary");
OADQUERYFILTERNODE qfn = (OADQUERYFILTERNODE)
queryDef.BuildFilterOperator(CQConstants.AD_BOOL_OP_AND);
qfn.BuildFilter("description",
CQConstants.AD_COMP_OP_LIKE, "foobar");
OAdResultset rs = (OAdResultset)
cqSession.BuildResultSet(queryDef);
rs.Execute();
In addition to the answer given above, note ClearQuest provides a file clearquest.bas that has all the constant definitions in there. In order to use that in C# you would create a new file and copy these constant definitions in a new class called CQConstants.
If you file an request for an enhancement, the ClearQuest team might consider adding a C# class you could use for the constant definitions.