It's all about the answers!

Ask a question

How to use javascript API to get all the users' ID/accounts in an role by the role name?


Albert Yao (5211118) | asked Dec 28 '12, 1:28 a.m.
edited Mar 21 '13, 12:20 p.m. by Ralph Schoon (57.1k23642)
If I know the role name in the project area, how to use javascript API to get all the users' ID/accounts in the role?
For example, how to get all the members' ID/accounts in the role "Scrum Master"?

Comments
Albert Yao commented Dec 28 '12, 1:35 a.m.

I find this:  https://jazz.net/forum/questions/65978/solved-get-users-with-a-role-on-a-teamarea,but this is for Java API, not for javascript.

Accepted answer


permanent link
Ralph Schoon (57.1k23642) | answered Mar 21 '13, 12:21 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
In RTC 3.x and RTC 4.x at least, it is not possible to access users and roles and the like from JavaScript. See https://jazz.net/wiki/bin/view/Main/AttributeCustomization for what is doable and also https://jazz.net/library/article/1093
Ralph Schoon selected this answer as the correct answer

2 other answers



permanent link
Ralph Schoon (57.1k23642) | answered Dec 28 '12, 11:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Dec 28 '12, 11:17 a.m.
Today, there is no way I would be aware of to get to that information in JavaScript. You can only access the contributor type attributes and get an UUID and the user name. Given a UUID you can set users in scripts too. However, there is no JavaScript API to access the project area and its data.

You would have to use the built in providers Lauren mentioned above. If that is not feasible this workshop will publish some more labs on JavaScript in January. It will however not publish anything on your specific request.

You can look if this approach http://jorgediazblog.wordpress.com/2012/06/27/work-item-customization-httpconector-and-oauth-in-rtc-4-0-for-oslc/ has a way to provide you with the information you need. I am not sure and rather pessimistic.

If it is impossible to get at the information you want you should consider to follow this blog and create a followup action instead.

permanent link
Lauren Hayward Schaefer (3.3k11227) | answered Dec 28 '12, 7:16 a.m.
JAZZ DEVELOPER
Hi,
I'm not sure how to get all of the users of a given role using javascript.  Depending on what you're trying to do, using Role Based User Lists may work for you: https://jazz.net/help-dev/clm/index.jsp?topic=%2F%2Fcom.ibm.team.workitem.doc%2Ftopics%2Ft_configuring_role_based_user_list.html.

Comments
Albert Yao commented Jan 07 '13, 2:45 a.m.
Hi,

I have created a "Role Based User List" value set "tester", but how to get the members of it?


For example, there is an attribute/field "tester" to use the value set, the options/list items in the UI are all the members in the role "tester", I can see all the members in the UI, but I want to know if there is a way to get the options by using javascript?


Ralph Schoon commented Jan 07 '13, 3:02 a.m. | edited Jan 07 '13, 3:03 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Hi Albert,

please check https://jazz.net/library/article/1093 Lab 4 talks about this.


Prasad Annamdasu commented Jan 09 '13, 8:20 a.m.

 Hi Ralph, 


I do have the similar problem. I didnt find any information related to javacode in the above linked article.



Ralph Schoon commented Jan 09 '13, 8:25 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

See http://rsjazz.wordpress.com/2012/12/09/analyzing-a-aroject-areas-members-and-roles-using-the-plain-java-client-libraries/

"If it is impossible to get at the information you want you should consider to follow this blog and create a followup action instead."

The article above shows Client API but you should be able to use the complementary server API for the same purpose. The trick is to find the service. It typically has a similar name, that can help.


Ralph Schoon commented Jan 09 '13, 8:29 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

And this Participant (FollowUp Action) http://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ finds an Approver using Roles. The API used is server API and should help you to get a grip at finding roles similar to the other blog post.

Your answer


Register or to post your answer.