It's all about the answers!

Ask a question

how can i get current user


chen fengmiao (7022631) | asked Dec 02 '11, 6:21 p.m.
i want customize attribute,how can i get current user(login this RTC user),please help me!thank you!

7 answers



permanent link
Ralph Schoon (54.9k23642) | answered Dec 03 '11, 10:18 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
i want customize attribute,how can i get current user(login this RTC user),please help me!thank you!


Depends on what you want to do in which version. In 3.x there is a capability to do "Attribute Customization" you can create a default value for a user attribute and select authenticated user to get the logged in user.

permanent link
chen fengmiao (7022631) | answered Dec 03 '11, 2:58 p.m.
i want customize attribute,how can i get current user(login this RTC user),please help me!thank you!


Depends on what you want to do in which version. In 3.x there is a capability to do "Attribute Customization" you can create a default value for a user attribute and select authenticated user to get the logged in user.


Hello,
i use RTC in 3.0.1. I using scripts for attribute customization in work item to validate something. but i don't get current user in script. How can i to do it? What function can get curent user in script? Can you provide some API and some example ? Thank you!

permanent link
Ralph Schoon (54.9k23642) | answered Dec 04 '11, 6:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
The scripting capabilities are still experimental - that is why you need to enable them in the advanced properties. This is what can be done: https://jazz.net/wiki/bin/view/Main/AttributeCustomization

I have looked into accessing users in the scripting and it does not really work as far as I know. It returns user ID's and I was not really capable of doing anything with it. I don not think that you can access the current user using the scripts.

permanent link
chen fengmiao (7022631) | answered Dec 04 '11, 10:07 a.m.
The scripting capabilities are still experimental - that is why you need to enable them in the advanced properties. This is what can be done: https://jazz.net/wiki/bin/view/Main/AttributeCustomization

I have looked into accessing users in the scripting and it does not really work as far as I know. It returns user ID's and I was not really capable of doing anything with it. I don not think that you can access the current user using the scripts.



I try create a default value for a user attribute eg:loginUser, and select authenticated user to get the logged in user,then I use "workitem.getValue(loginUser)" to get authenticated user ,but it return "null",why?

if I use Java not javascript to get current use,which API can I use,can you offer me some useful example? Thank you!

permanent link
Ralph Schoon (54.9k23642) | answered Dec 05 '11, 2:46 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
The default vale will only be set once and essentially sets the value to the creator of the work item, not the current user.

I would suggest to add your need here https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=169823. The current user would have to be exposed in the script UI.

Please read this topic completely and carefully: https://jazz.net/wiki/bin/view/Main/AttributeCustomization. It describes what can be done today using Java Script and how.

To read the attribute please follow the above link and try to add the dependent attribute into the configuration. That however will not help you for the reason above. In addition I experienced that the script API currently returns the user ID only and I found no way to use it for anything but printing the ID. I was even not able to set a contributor using the ID I retrieved.

You can also follow https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Providing_new_customizations_imp to implement your own attribute value provider. I have no example for it. Inthe Java API you can access the current user using

IContributor loggedIn = TeamRepository.loggedInContributor();


That is about all I know.

permanent link
chen fengmiao (7022631) | answered Dec 06 '11, 11:26 a.m.
Hello rschoon:

value content="${currentUser}


I set a attribute's default value is about it.This attribute display the current user,not the creator of the work item.but I use "workItem.getValue(attributeId)" to get about attribute value,it return null.


You said :

In addition I experienced that the script API currently returns the user ID only and I found no way to use it for anything but printing the ID. I was even not able to set a contributor using the ID I retrieved.



this mean you can return current use name ID,I currently need the current use name ID ,how can I get ID?
Thank you!

permanent link
Ketan Karnawat (112) | answered Jul 09, 8:43 a.m.

 Hello If you get Id, using workitem.getvalue() method please try workitem.getLabel(). this will give you actual name instead of ID.

Your answer


Register or to post your answer.