Sorry - I was writing this without a compiler.. :)
Try this:
GenericEntity Manager = (GenericEntity)ge.Values[6].Value;
dr[6] = FieldValueToString(Manager.Values[0]);
I was binding my data to Datagrid view.I was able to bind data in work items I cud execute and bind data to it but the result in the Manager i was getting is in Hexadecimal format.How can i get it in string format??
Please sign in to leave a comment.
Sorry - I was writing this without a compiler.. :)
Try this:
GenericEntity Manager = (GenericEntity)ge.Values[6].Value;
dr[6] = FieldValueToString(Manager.Values[0]);
You can ask for the field "Manager.DisplayName". This will give you a User object with the DisplayName field populated with its value
This is the code
private void btnGetWorkItems_Click(object sender, EventArgs e)
{
#region Work Items
MyWorkItemsQuery query = new MyWorkItemsQuery();
query.ItemsType = WorkItemType.Task;
query.ItemsTypeSpecified = true;
query.ItemsFilter = WorkItemFilter.IAmAManager;
query.ItemsFilterSpecified = true;
query.ItemsState = WorkItemState.Active;
query.ItemsStateSpecified = true;
query.Fields = new string[] { "SYSID", "Name", "Importance", "DueDate", "StartDate", "PercentCompleted", "Manager.DisplayName", "CreatedOn", "State", "Parent" };
QueryResult qr = x.Query(query);
#endregion
#region Custom Code
DataTable dt = new DataTable();
dt.Columns.Add("SYSID", typeof(String));
dt.Columns.Add("Name", typeof(String));
dt.Columns.Add("Importance", typeof(String));
dt.Columns.Add("DueDate", typeof(String));
dt.Columns.Add("StartDate", typeof(String));
dt.Columns.Add("PercentCompleted", typeof(String));
dt.Columns.Add("Manager.DisplayName", typeof(string));
dt.Columns.Add("CreatedOn", typeof(string));
dt.Columns.Add("State", typeof(string));
dt.Columns.Add("Parent", typeof(string));
DataRow dr;
foreach (GenericEntity ge in qr.Entities)
{
dr = dt.NewRow();
dr[0] = FieldValueToString(ge.Values[0]);
dr[1] = FieldValueToString(ge.Values[1]);
dr[2] = FieldValueToString(ge.Values[2]);
dr[3] = FieldValueToString(ge.Values[3]);
dr[4] = FieldValueToString(ge.Values[4]);
dr[5] = FieldValueToString(ge.Values[5]);
dr[6] = FieldValueToString(ge.Values[6]);
dr[7] = FieldValueToString(ge.Values[7]);
dr[8] = FieldValueToString(ge.Values[8]);
dr[9] = FieldValueToString(ge.Values[9]);
dt.Rows.Add(dr);
}
dataGridView1.DataSource = dt;
#endregion
x.Logout();
}
I am not able to retrieve manager and other ids like parent etc.Help me out in giving an example.
I think the following would work in your case:
GenericEntity Manager = (GenericEntity)ge.Values[6];
dr[6] = FieldValueToString(Manager.Values[0]);
I m not able to execute with the code u sent..
This is the error it displays when i m trying to debug..
Error 2 Cannot convert type 'Clarizen_ex.ClarizenSvc.FieldValue' to 'Clarizen_ex.ClarizenSvc.GenericEntity' C:\Documents and Settings\Bissu\Desktop\SAntosh\Clarizen ex\Clarizen ex\GetWorkItems.cs 90 41 Clarizen ex