Official comment
Hi Armand,
Here is an example of working with the "RecursiveQuery" in C#:
//Login
var clarizenClient = new Clarizen { Timeout = 60 * 1000, EnableDecompression = true };
var options = new LoginOptions();
options.ApplicationId = "Sample c# client";
var srvDef = clarizenClient.GetServerDefinition("username", "password", options);
clarizenClient.Url = srvDef.ServerLocation;
var lr = clarizenClient.Login("username", "password", options);
//Use query
var recursiveQuery = new RecursiveQuery
{
TypeName = "WorkItem",
Fields = new[] { "Name", "Parent" },
Levels = 1, //level of item that you want to retrieve
RootItemId = new EntityId { TypeName = "WorkItem", Value = "1dz79zji4khiafgzfpl179p5d5792" } //Id of the root work item
};
var recursiveQueryResults = clarizenClient.Execute(new[] { recursiveQuery });
if (recursiveQueryResults.Any())
{
var recursiveQueryResult = (QueryResult)recursiveQueryResults.First();
if (recursiveQueryResult.Success)
{
foreach (var entity in recursiveQueryResult.Entities)
{
Console.WriteLine(new String('*', 15));
Console.WriteLine("Work Item Id - " + entity.Id.Value);
Console.WriteLine("Work Item Name - " + entity.Values[0].Value);
if (entity.Values[1].Value != null)
Console.WriteLine("Work Item Parent - " + ((Entity)entity.Values[1].Value).Id.Value);
}
}
}
}
Result:
***************
Work Item Id - 2gptooj3emdqmk3zmxeo51szq6671 //This is the root project
Work Item Name - Design Review
Work Item Parent - 1dz79zji4khiafgzfpl179p5d5792
***************
Work Item Id - 2gptooj3emdqmk3zmxeo51szq6677
Work Item Name - Mockup Ready
Work Item Parent - 1dz79zji4khiafgzfpl179p5d5792
***************
Work Item Id - 2gptooj3emdqmk3zmxeo51szq6683
Work Item Name - Engineering Sample
Work Item Parent - 1dz79zji4khiafgzfpl179p5d5792
***************
Work Item Id - 2gptooj3emdqmk3zmxeo51szq6689
Work Item Name - Customer Sample
Work Item Parent - 1dz79zji4khiafgzfpl179p5d5792
***************
Work Item Id - 1dz79zji4khiafgzfpl179p5d5808
Work Item Name - Industry Design Roadmap
Work Item Parent - 1dz79zji4khiafgzfpl179p5d5792
***************
Work Item Id - 2gptooj3emdqmk3zmxeo51szq6587
Work Item Name - Concept DCP
Work Item Parent - 1dz79zji4khiafgzfpl179p5d5792
I hope this helps,
Elad