How to get the current userID in a condiftion javascript
4 answers
Please see answer https://jazz.net/forum/questions/133477/work-item-customization-getting-current-user-as-logged-in-user/184711 for how to get the item ID for the user that runs the operation. Thanks to Amaury Quintero for providing this info.
Maybe can be helpful for someone trying to get the current user using JS API (dojo). I've solved this need like that:
That var has a property called itemId which retrieves the user internal ID
like _JPlIwJMVEeOQyJhn3MD2hQ, such property can be compared with the value retrieved from an attribute
like com.ibm.team.workitem.attribute.owner.
With this concept in mind, you can use the Attribute customizations and create a Condition Script used in cooperation with the built-in Advisor Read-Only Attributes For Condition.
var currentUser = com.ibm.team.repository.web.client.session.getAuthenticatedContributor;
That var has a property called itemId which retrieves the user internal ID
like _JPlIwJMVEeOQyJhn3MD2hQ, such property can be compared with the value retrieved from an attribute
like com.ibm.team.workitem.attribute.owner.
With this concept in mind, you can use the Attribute customizations and create a Condition Script used in cooperation with the built-in Advisor Read-Only Attributes For Condition.
As far as I can tell, there is no way to access the user ID of the user that is currently logged in and working with the work item in JavaScript. See https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript for what is possible. From the same page, I would assume it would be possible to use the JavaAPI to create a condition. Although I have note yet tried that myself, I would assume that in the condition plugin you would be able to access the logged in user.