cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

viewproject history using mksapi jar doesn't return all required fields

ptc-4709288
1-Visitor

viewproject history using mksapi jar doesn't return all required fields

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

ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

1 REPLY 1

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.

Announcements


Top Tags