Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hello, I am trying to run "viewprojecthistory" using mksapi (java api - mksapi.jar version 4.11.3238) but even if I set required fields it doesnt return the values of these fields.
In the response I see only "revisions" as the field returned. (Please find the comment in the code where it fails)
The code looks as follows.
Command command = new Command(Command.SI, "viewprojecthistory");
SelectionList selectionList = new SelectionList();
OptionList optionList = new OptionList();
optionList.add(new Option("project", mksProjectName));
optionList.add(new Option("yes"));
MultiValue mv = new MultiValue(",");
mv.add("labels");
mv.add("name");
mv.add("memberrev");
mv.add("state");
optionList.add(new Option("fields", "labels,name,memberrev,state"));
command.setOptionList(optionList);
command.setSelectionList(selectionList);
Response resp = api.runCommand (command);
for (WorkItemIterator i = resp.getWorkItems();i.hasNext();) {
WorkItem wi = i.next();
String labels = wi.getField("labels").getValueAsString(); // Fails, there is no field "labels" in workitem
String rev = wi.getField("memberrev").getValueAsString(); // Fails, there is no field "memberrev" in workitem
String state = wi.getField("state").getValueAsString(); // Fails, there is no field "state" in workitem
}
What is going wrong here?
regards,
Ratheesh
Solved! Go to Solution.
Ratheesh,
Please make sure that you are using the actual field names and not the display names in your code (you can find these in the field properties in the Administration Client.)
Also, ensure that the fields you are working with are in fact attached to the type for the workitem and are set as a visible field.
When debugging, did you check that you were getting the workitem ID correctly? If this was coming back with bad values, it could also cause the fields to not be found.
Ratheesh,
Please make sure that you are using the actual field names and not the display names in your code (you can find these in the field properties in the Administration Client.)
Also, ensure that the fields you are working with are in fact attached to the type for the workitem and are set as a visible field.
When debugging, did you check that you were getting the workitem ID correctly? If this was coming back with bad values, it could also cause the fields to not be found.