It's all about the answers!

Ask a question

How to fetch role name using role ids using plain Java API?

Andrew Ciaz (59163) | asked Apr 29 '20, 6:24 a.m.

 Hi all,

I want to find out team area roles for the user and I used below code to for role ids:

but I want name of the role please give me API to fetch role name using its id.

Alternatively, I tried 

IRole2[] contributorRoles = (IRole2[]) process.getContributorRoles(contributor, projectArea, null);

But it returns the roles of project area also. So it is not useful to me. I need only team area roles.

Please provide the right API

Accepted answer

permanent link
Luca Martinucci (1.0k396112) | answered Apr 29 '20, 9:51 a.m.
edited Apr 29 '20, 9:52 a.m.
Try this code snippet.
It used to work for me.

String URI = ....;
ITeamRepository  teamRepository = TeamPlatform.getTeamRepositoryService().getTeamRepository(URI);
IProcessClient  processClient = (IProcessClientService) teamRepository.getClientLibrary(IProcessClientService.class);
// IProcessArea can be a Project Area, or a Team Area
ITeamArea teamArea = ...;
IRole[] processAreaRoles = getProcessAreaRoles(teamArea );
IContributor contributor = ...;
IRole[] contributorRoles = teamArea .getRoleAssignments(contributor, processAreaRoles);
for (int i=0; i<contributorRoles.length; i++) {
IRole contributorRole = contributorRoles[i];
IRole2 contributorRole2 = (IRole2) contributorRole;
Andrew Ciaz selected this answer as the correct answer

One other answer

permanent link
Andrew Ciaz (59163) | answered May 11 '20, 4:22 a.m.

 @Luca Martinucci thanks for the help

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.