WI attribute customization: default subscribers list with javascript
Hi,
I want to add a default subscribers list on specific work item based on chosen work item category.
This is my JavaScript code:
dojo.provide("com.apisit.users.list");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.string");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.apisit.users.list", null, {
getValueSet: function(attribute, workItem, configuration) {
var wi_type = workItem.getValue(WorkItemAttributes.TYPE);
var wi_category = workItem.getValue(WorkItemAttributes.FILED_AGAINST);
var DefaultSubscribers = [];
DefaultSubscribers.push("_thFDcGJzEd-408oU3hXeOA");
DefaultSubscribers.push("_i0ozwDgrEeC-ZOxsQ_2mZQ");
DefaultSubscribers.push("_q13YBAzMEd-3T9F8SUEaUw");
if(wi_type=="bug" && wi_category == "_X-ruUA0hEeKkzKqDw-rhOA")
{
return DefaultSubscribers;
}
}
});
})();
But this doesn't work :(
I know that I can make UsersList, but I can't do it for specific wi category and wi type except in this way I think...
What am I doing wrong?
Accepted answer
Milan,
this will not work and you can't get it to work with JavaScript.
As described in https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript there is only limited support. You can effectively access attributes of the work item the JavaScript runs. You can not access other data such as attachments, work item links, team areas and a lot more.
Since these questions come up over and over again, we tried to put some information onto https://jazz.net/library/article/1093 (Lab 5 the beginning).
https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ might be a valid approach.
this will not work and you can't get it to work with JavaScript.
As described in https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript there is only limited support. You can effectively access attributes of the work item the JavaScript runs. You can not access other data such as attachments, work item links, team areas and a lot more.
Since these questions come up over and over again, we tried to put some information onto https://jazz.net/library/article/1093 (Lab 5 the beginning).
https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ might be a valid approach.
Comments
Hi Ralph,
I supposed this will be the answer.
The problem is that we have master project area which shares its process template to all other project areas, and that's the reason I wanted to do this with JavaScript Calculated Values.
I'll try something with java.
Thanks,
Milan
Good luck Milan. Java Provider have to be deployed in the client and the server. Another approach could be a save work item participant. My blog talks about the API and some examples here: https://rsjazz.wordpress.com/2012/08/02/subscribing-to-a-work-item-using-the-java-api/ I think it is client API, but client and server API are very similar here.