Question

I am trying to create and update a RTC workitem by using plain Java API. I am able to set most of the attributes I need except "Found In".

I tried something like:

IAttribute FoundInAttribute = workItemClient.findAttribute(projectArea, "Found In" , null); wc.getWorkItem().setValue(FoundInAttribute, "The value I want to set");

And I got an exception saying setValue() is expecting an IDeliverableHandle object rather than String.

How can I get the IDeliverableHandle I need?

Thanks, Kane

Was it helpful?

Solution

The OP Kane Zeng reports in the comments that, out of the following solutions below, one is working:

I use:

IDeliverableHandle deliverable = 
   workItemClient.findDeliverableByName(projectArea, currentFoundIn,
   IDeliverable.SMALL_PROFILE ,null);

and I can get what I need now


Original answer:

That thread mentions:

IDeliverableHandle deliverable= ... // Find a deliverable using one of
the IWorkItemClient#findDeliverable* methods

IAttribute foundIn= workItemClient.findAttribute(project,
  IWorkItem.FOUND_IN_PROPRTY, monitor);
workItem.setValue(foundIn, deliverable);

That seems similar to this thread:

The attributes can be acquired using

IWorkItemCommon#findAttribute(IProjectAreaHandle projectArea, 
  String attributeId, IProgressMonitor monitor);

So for the Found In attribute, you would do the following

IAttribute foundIn= workItemClient.findAttribute(projectArea,
  IWorkItem.FOUND_IN_PROPERTY, monitor);
IDeliverableHandle deliverable = (IDeliverableHandle)workItem.getValue(foundIn);

A more recent answer gives:

IAttribute foundInAttribute = myWorkItemClient.findAttribute(projectAreaHandle, "foundIn" , null);
IDeliverableHandle foundInDeliverableHandle = (IDeliverableHandle) currentWI.getValue(foundInAttribute);
if (foundInDeliverableHandle != null){
    IDeliverable deliverable = (IDeliverable) this.repository.itemManager().fetchCompleteItem(foundInDeliverableHandle, IItemManager.DEFAULT, null);
} 

(you would find a similar approach there)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top