work item customization: getting current user as logged in user
Accepted answer
Comments
Hi Amaury,
Hi Milan, in effect this only works in Web because the package we are using is web (dojo.require("com.ibm.team.repository.web.client.session.Session");
I'm trying to use this code to set a defaultvalue, but declaring getAuthenticatedContributor causes nothing to return. I've tried debugging, and both variables do get defined.
Any idea why this wouldn't work?
dojo.provide("ba.workitem.defectEscalation.gscOwner.defaultvalue");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("com.ibm.team.repository.web.client.session.Session");
(function(){
var getAuthenticatedContributor = com.ibm.team.repository.web.client.session.getAuthenticatedContributor;
dojo.declare("ba.workitem.defectEscalation.gscOwner.defaultvalue", null, {
getDefaultValue: function(attribute, workItem, configuration){
var loggedinUser = getAuthenticatedContributor().itemId;
return loggedinUser;
}
});
})();
This would only work in the Web UI as far as I know.
Should it work in 5.0.2 as well?
This ONLY works in the web UI, as far as I can tell.
@rschoon - are there any plans to make it working in Javascript in Eclipse client as well?
I don't know. Request an enhancement, or use the Java capabilities for the moment.
2 other answers
Comments
I think you can only get the authenticated user in Java based attribute customization. Search for provider in my blog for the example post.
He wanted Javascript access.. I think that s still not available, right?
I realized that he wanted JavaScript too late. As far as I can tell, there is no way to know the looged-in user from JavaScript today.
Are there existing enhancements to provide the same access to attributes of a work item through JavaScript that can be done in Java? In addition to current user, it would be helpful to have access to Links and Approvals.
1 vote
So, is there possible to call REST service from JavaScript using DOJO in RTC?
I don't know.This would be a possible approach using Java: https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/
Ok Ralph, thanks for the answer.
I would suggest to follow the links in the post I sent you. Follow the links in the section at the top saying
"If you are just starting with extending Rational Team Concert and using the API’s for automation, start........"
Hi Ralph,
Milan, as shown in the blog, and described here here: https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Configuring_additional_script_pa you need to configure the provider. https://jazz.net/library/article/1093 Lab 5 explains it in more detail for some ofthe examples, I believe. You search the provider configuration e.g. using the name. You modify the entry, remove the trailing / and add a new closing statement. In between you add the parameters.
Hi Ralph,
Please look into https://rsjazz.wordpress.com/2012/12/09/analyzing-a-aroject-areas-members-and-roles-using-the-plain-java-client-libraries/ and search for IRole2 - that is the interface that provides you with the role name.
Please try search on my blog, searching for "role name" would have found you the right article.
Milan, you don't need to call a WebService. I think the best solution is to create a Data Connector for the Server Side JavaScript to work, then you need to differentiate when the code is running on client or when is running on server. That way you have all control about the code and you can get the current user on server side
Comments
I can only guess. this is probably due to the fact that you have to specify the type this is returning, as descried in my blog, and you did not specify the correct type. Or it is some other kind of deployment issue. Are you trying to deploy on Jetty?
Hi Ralph, I solved the issue, the problem was that I didn't defined public part bellow public class and above public String getValue(IAttribute attribute, IWorkItem workItem...
You probably failed to deploy the extension on the server. You need to deploy it on the server as well as in Eclipse.
1 vote
Hi Ralph,
Milan, as all attribute customizations, the Java versions require to define dependent attributes that trigger changes. This may be an issue, I am not sure for which attribute to create a dependency here. I always had conditions that were dependent on some attribute. So maybe this can't be done. I am not sure Milan, sorry. I would have to spend time on this.
Ralph, I thing this is worth of investigating, and I 'll also try to spend some time on this. Our management has specific requirements which can only be done by implementing these Java API-s to work items.
Milan, I am pretty sure there are enhancement requests to make things read only by role. there are also enhancement requests for making things invisible by role. I can't look it up right now. It might make sense to search for these work items and add your support.
There are API's for time tracking data. Essentially there is a special link on the work item, as far as I know. I know customers have created their own tools to maintain them. This can only be achieved by Java or REST API's. For the reasons I stated in the workshop JavaScript does not provide an API. You can search this forum, about details, there might be some.
Yes, you can create follow up actions and other means to send mail This has also been discussed here several times. You can start here for an example. I would suggest to open new questions if you need more answers on the forum.