Post

2 followers Follow
0
Avatar

Resource management Query SOAP API To get planned work for a user

Hi 

We were trying to get a resource's planned work for a particular period using resource management class through SOAP call.

here is the code Iam using C#

LoginDetails ld1 = new LoginDetails();
ld1 = LoginDetails.Login();

BaseMessage[] messagesArray = new BaseMessage[0];
ResourceManagementQuery query = new ResourceManagementQuery();
EntityId[] arrayId = new EntityId[1];
EntityId entityID = new EntityId();

entityID.TypeName = "user";
entityID.Value = "b8676aba-79e4-4fc5-996b-d36a7f9b54bb";// currentUser.Guid;
arrayId[0] = entityID;

query.ResourceEntitiesIds = arrayId;

ResourceManagementQuerySetting qs = new ResourceManagementQuerySetting();

FieldsToBeSelected fieldstobeSelected = new FieldsToBeSelected();
FieldsToBeSelected[] fieldsArray = new FieldsToBeSelected[1];
String[] fields = new String[1];

fields[0] = "Name";
//fields[1] = "ReportedDate";
//fields[2] = "Project.Name";
//fields[3] = "WorkItem.Name";
//fields[4] = "Duration";
//fields[5] = "Price";
//fields[6] = "Project.PercentCompleted";
//fields[7] = "C_TimeType";
fieldstobeSelected.FieldNames = fields;
fieldstobeSelected.TypeName = "User";
fieldsArray[0] = fieldstobeSelected;
qs.Fields = fieldsArray;
qs.HoursView = true;
qs.LoadOrAvailability = ResourceLoadValueType.Load;
qs.ReportingPeriod = ReportingPeriodType.Daily;
qs.WorkOrRemainingEffort = ResourceLoadBaseType.Work;
qs.HoursViewSpecified = true;
qs.LoadOrAvailabilitySpecified = true;
qs.WorkOrRemainingEffortSpecified = true;

ResourceManagementQueryGlobalFilters globalFilters = new ResourceManagementQueryGlobalFilters();
TimeFilter timeFilter = new TimeFilter();
timeFilter.From = Convert.ToDateTime("5/01/2016");
timeFilter.From = Convert.ToDateTime("5/07/2016");
globalFilters.TimeFilter = timeFilter;

 

ResourceManagementQueryDefinition qd = new ResourceManagementQueryDefinition();
qd.GlobalFilters = globalFilters;
qd.Setting = qs;

query.Definition = qd;

messagesArray = new BaseMessage[] { query };
Result[] results = ld1.ClarizenClient.Execute(messagesArray);
ResourceManagementQueryResult qr = (ResourceManagementQueryResult)results[0];

after executing the code I am getting an error "All entities in list should belong to class Group".

Actually i want to know what is the type name and field name  i should query for to get planned work?

 

 

 

Balamurugan P Answered

Please sign in to leave a comment.

1 comment

0
Avatar

Hi Balamurugan P,

Please try entityID.TypeName = "User"; (instead of "user"). 

Add a comment here if you still have issues.

Hope this helps,

Ophir

Ophir Kenig 0 votes
Comment actions Permalink