It's all about the answers!

Ask a question

How to get attribute value of other work item using Calculated value scripts


Shahana Shaikh (133) | asked Aug 20 '19, 8:51 a.m.
edited Aug 20 '19, 10:47 a.m. by Ralph Schoon (63.1k33646)

 I want to fetch value of an attribute from other work item by using its workitem ID and use it in current work item. Can we do this using calculated scripts?

Accepted answer


permanent link
Ralph Schoon (63.1k33646) | answered Aug 20 '19, 10:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.

Shahana Shaikh selected this answer as the correct answer

Comments
Shahana Shaikh commented Aug 21 '19, 2:43 a.m.

 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();
}
});
})();


Davyd Norris commented Aug 21 '19, 8:00 p.m.
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.

Shahana Shaikh commented Aug 23 '19, 12:15 a.m.

Thanks Davyd 

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.