Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to get Contributor Value

 I have one custom attribute, the type is contributor type. The problem is I can't get the value of the attribute. I have followed the code that has been provided in  "https://jazz.net/forum/questions/202216/how-to-obtain-the-value-of-a-custom-contributor-field-via-a-rtc-participant-plugin" but it always capture null value even though there is a contributor assigned in that attributes. Is there anyone who can give suggestion what should I do and what happened with that?


Here is my code:

import com.ibm.team.repository.common.IContributor;
import com.ibm.team.repository.common.IContributorHandle;
import com.ibm.team.repository.service.IRepositoryItemService;
        
IWorkItemServer workitemserver= getService(IWorkItemServer.class);
IAttribute attribute = workitemserver.findAttribute(workItem.getProjectArea(), "customerExperience", monitor);
IContributorHandle contributorHandle = (IContributorHandle) workItem.getValue(attribute);
IContributor contributor = (IContributor) itemService.fetchItem(contributorHandle, null);
 

0 votes

Comments

From a quick look at the code here, it looks like you're missing a few dependencies for
workItem in "workItem.getValue"
itemService in "itemService.fetchItem"

Are these two properly declared in your code?

Yeah I have declare it before. I can get the value of string type attributes , timestamp and enumeration. I only can’t get value if it’s contains a contributor type.


It’s quite weird,  I can get the owner value and all the contributors inside the team area. However, I can’t get the value if I retrieve the value directly from the attributes and the subscriber list also it always capture null value (0 subscribers). 

That's why I don't know the problem, do u have any idea? 

Can you retrieve the value of other custom attributes?

Do you have other project areas to test your code on? Or is it just a single project area?

Not being able to get the subscribers might be caused by an external issue other than the API, so if possible try to check if you can get subscribers in a different project area.

Yeah, I can get the custom attributes as long as the type is not contributor or contributor list.


I have tried also in other project areas, it shows the same problem.

Is it because I used the incorrect code to retrieve the contributor value?

The code looks ok as long as the custom attribute ID is correct.

Do the other work item API for getting contributors work?
i.e.
getCreator, getOwner & getResolver?

If I retrieve the value of built-in attributes for contributor types (Owner, Modifier, Creator, Resolver), it's working. At the first, I think maybe it's because the library but I can get the the build in contributor attributes. 


That is why I don't know what is wrong with it

Can we check whether "customerExperience" is returning a valid attribute?

After

IAttribute attribute = workitemserver.findAttribute(workItem.getProjectArea(), "customerExperience", monitor);


Try:

attribute.getAttributeType()


and see if Contributor is correctly returned

Yeah, it is return correctly,


After that when I used this code:

workItem.getValue(attribute); then I want to print something in tomcat. It don't show anything and skip all the other printing

showing 5 of 8 show 3 more comments


One answer

Permanent link

If you have to print something in Tomcat you are doing it wrong. If you don't follow the Extensions workshop https://jazz.net/library/article/1000 to be able to debug in Jetty, it is pretty much wasted time to try to help as well.

Neither do I see any tests to the instance or null or anything sanity checking code I would expect if you don't have anything better than System.out.println()

Follow the workshop and set up your environment properly.

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Jul 07 '17, 4:32 a.m.

Question was seen: 2,001 times

Last updated: Jul 19 '17, 3:51 a.m.

Confirmation Cancel Confirm