How to get attribute value of other work item using Calculated value scripts
Accepted answer
For all I know this is not supported in attribute customization. See https://rsjazz.wordpress.com/2016/07/15/rtc-process-customization-what-you-can-and-cannot-do/. With attribute customization I mean what is covered in https://jazz.net/wiki/bin/view/Main/AttributeCustomization and https://jazz.net/library/article/1093 .
There is a work item proxy which is not supported API that has been used for access across links https://www.google.com/search?q=wiork+item+proxy+site%3Ajazz.net. It might be possible to use REST and other calls as well.
Comments
Thanks Ralph.
I tried the work item proxy but as soon as i added (var WorkItemProxyFactory = com.ibm.team.workitem.web.cache.internal.WorkItemProxyFactory) to my script it stopped working. Any suggestions?
dojo.provide("example.calculated.testScript");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("com.ibm.team.workitem.web.cache.internal.WorkItemProxyFactory");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var WorkItemProxyFactory = com.ibm.team.workitem.web.cache.internal.WorkItemProxyFactory;
dojo.declare("example.calculated.testScript", null, {
getValue: function(attributeId, workItem, configuration) {
var workitem = workItem.getLabel('workitem_att');
var index = workitem.indexOf(':');
if(index > 0){
var workitemId = workitem.substr(0,index);
}
return workitemId.toString();
}
});
})();
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("com.ibm.team.workitem.web.cache.internal.WorkItemProxyFactory");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var WorkItemProxyFactory = com.ibm.team.workitem.web.cache.internal.WorkItemProxyFactory;
dojo.declare("example.calculated.testScript", null, {
getValue: function(attributeId, workItem, configuration) {
var workitem = workItem.getLabel('workitem_att');
var index = workitem.indexOf(':');
if(index > 0){
var workitemId = workitem.substr(0,index);
}
return workitemId.toString();
}
});
})();
WorkItemProxy and WorkItemProxyFactory are both available in the web client only, so your script will fail if the code is run by the Eclipse client or the server.
It may be that your calculated value script is being run on the server side. Comment out the proxy lines, put a console.log('Hi there'); line somewhere in your script and then try running it with the web console open. If you see the comment in the web console then your code is running on the client, if you see it in ccm.log then it's running on the server.
Thanks Davyd