It's all about the answers!

Ask a question

How to get Contributor Value

Ardy Lesmana (134) | asked Jul 07 '17, 4:32 a.m.

 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  "" 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:

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);

Andy Chen commented Jul 18 '17, 11:32 p.m.

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?

Ardy Lesmana commented Jul 19 '17, 1:41 a.m.

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? 

Andy Chen commented Jul 19 '17, 1:52 a.m. | edited Jul 19 '17, 1:58 a.m.

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.

Ardy Lesmana commented Jul 19 '17, 2:01 a.m.

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?

Andy Chen commented Jul 19 '17, 2:17 a.m.

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

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

Ardy Lesmana commented Jul 19 '17, 2:22 a.m.

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

Andy Chen commented Jul 19 '17, 2:32 a.m. | edited Jul 19 '17, 2:32 a.m.

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


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



and see if Contributor is correctly returned

Ardy Lesmana commented Jul 19 '17, 3:37 a.m.

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
Ralph Schoon (63.1k33646) | answered Jul 19 '17, 3:50 a.m.
edited Jul 19 '17, 3:51 a.m.

If you have to print something in Tomcat you are doing it wrong. If you don't follow the Extensions workshop 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.

Your answer

Register or 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.