Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

 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?

0 votes


Accepted answer

Permanent link

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

0 votes

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

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 

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Aug 20 '19, 8:51 a.m.

Question was seen: 2,052 times

Last updated: Aug 23 '19, 12:15 a.m.

Confirmation Cancel Confirm