2

I am using below code and it returns some information about "Filed Against" attribute. But there I am not able to find attribute data. Please help

IAttribute someAttribute= workItemClient.findAttribute(projectAreaHandle, workItem.CATEGORY_PROPERTY, monitor);

Using below code to find out the work item by Id :

workItemClient = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
                int id = new Integer("339406").intValue();  
                IWorkItem workItem = workItemClient.findWorkItemById(id, IWorkItem.FULL_PROFILE, monitor);

using this work item I want to fetch parent and children like Epic and story work items related to the work item. And then there attributes like story status, story planned for etc.

Rinkal Garg
  • 62
  • 1
  • 10

1 Answers1

1

From this thread:

You can't just put a string in there, I think.
You have to find the category object from the string and then put in the ICategory object.

That means:

private static String CATEGORY_NAME = "UI1"; 
List<ICategory> findCategories = workItemCommon.findCategories(projectArea, ICategory.FULL_PROFILE, monitor); 
    for(ICategory category : findCategories) { 
          if(category.getName().contains(CATEGORY_NAME)){ 
              filedAgainstAttribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.CATEGORY_PROPERTY, auditableClient, monitor); 
                    filedAgainstExpression = new AttributeExpression(filedAgainstAttribute, AttributeOperation.EQUALS, category);
       } 
  } 
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 3
    I spent a few very painful hours myself to do something useful with the RTC APIs. From that point of view, I wish I could upvote this multiple times. Just to make up for the energy that it probably cost you at some point to acquire the knowledge ... – GhostCat Mar 18 '18 at 13:53
  • @GhostCat Can you please share the code snippet, I am trying to find out the attributes data and I only have feature id, using that i have work item but further I have no idea how to fetch parent and children of the work item and then their attributes – Rinkal Garg Mar 19 '18 at 12:05
  • @VonC, Thanks for the response, actually I have feature Id and need to create one report which contains all parent and child work items in that and all their attributes. Any help would really be appreciated. I am struggling with the RTC APIs from last one week but didn't get any luck. Please help – Rinkal Garg Mar 19 '18 at 12:08
  • 1
    @RinkalGarg Your question did not mention anything about and child work items: can you edit your question to show a bit more of the code you have and of what is missing? – VonC Mar 19 '18 at 12:17
  • 1
    @RinkalGarg I didn't work this specific thing. It was more of a generic rant about how painful working it is to work with RTC APIs. Sorry pal, no specific code that I could pass along here. If I had that, I would have written an answer already ;-) – GhostCat Mar 19 '18 at 12:20
  • 1
    @RinkalGarg Apparently, findLinksBySource is key (as in https://jazz.net/forum/questions/70215/fetching-parent-workitem-using-plain-java-api?redirect=%2Fforum%2Fquestions%2F70215%2Ffetching-parent-workitem-using-plain-java-api). Regarding attributes: https://jazz.net/forum/questions/84545/how-to-get-work-item-found-in-attribute-value – VonC Mar 19 '18 at 12:41
  • @VonC Thanks for you help, Now I have parent and child links with me. Is there any way to find out work item using that link or if we can cast that link into IWorkItem. Please respond. – Rinkal Garg Mar 20 '18 at 07:58