How to get value of custom attribute of RTC WI .
![](http://jazz.net/_images/myphoto/8771a2a070a5b6d96e917a60ff3dd48f.jpg)
We have created two custom attribute in Defect workflow .
1) Current state: which get the calculated value by using WorkItemAttributes.STATE
2) Assingned to TechLead: This is of type contributor where user can choose one techlead from multiple set/
Now we want to write a calculated script which can set the "Owned by" value to the "assigned Tech lead" attribute value.
I am not able to get the value (Techlead name) of "Assigned to TechLead" attribute .
Please help .
+Navneet
1) Current state: which get the calculated value by using WorkItemAttributes.STATE
2) Assingned to TechLead: This is of type contributor where user can choose one techlead from multiple set/
Now we want to write a calculated script which can set the "Owned by" value to the "assigned Tech lead" attribute value.
I am not able to get the value (Techlead name) of "Assigned to TechLead" attribute .
Please help .
+Navneet
Accepted answer
![](http://jazz.net/_images/myphoto/8771a2a070a5b6d96e917a60ff3dd48f.jpg)
So I was able to get this to work in a test project area. Note that my STATE is different than yours, so you'll need to change that. I tried to use the same attribute for Technical Lead as you did.
Since you are making it a calculated value, RTC *assumes* that nobody else will change it other than the script, so that is why I get the owner and return the owner if it is not a defect or defect but not the right state. If not, the if owner is set by someone else, it gets ignored. I also did var's for everything so I could print things for debugging
dojo.provide("org.example.CalculatedOwner");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
dojo.declare("org.example.CalculatedOwner", null, {
getValue: function(attributeId, workItem, configuration) {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var wiType = workItem.getValue(WorkItemAttributes.TYPE);
var wiState = workItem.getValue(WorkItemAttributes.STATE);
var wiTechLead = workItem.getValue("com.wiley.workitem.attribute.assignedBA");
var wiOwner = workItem.getValue(WorkItemAttributes.OWNER);
if (wiType === "defect" && wiState === "com.ibm.team.workitem.defectWorkflow.state.s1" ) {
return wiTechLead;
} //type = defect
else
return wiOwner;
}
});
})();
Since you are making it a calculated value, RTC *assumes* that nobody else will change it other than the script, so that is why I get the owner and return the owner if it is not a defect or defect but not the right state. If not, the if owner is set by someone else, it gets ignored. I also did var's for everything so I could print things for debugging
dojo.provide("org.example.CalculatedOwner");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
dojo.declare("org.example.CalculatedOwner", null, {
getValue: function(attributeId, workItem, configuration) {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var wiType = workItem.getValue(WorkItemAttributes.TYPE);
var wiState = workItem.getValue(WorkItemAttributes.STATE);
var wiTechLead = workItem.getValue("com.wiley.workitem.attribute.assignedBA");
var wiOwner = workItem.getValue(WorkItemAttributes.OWNER);
if (wiType === "defect" && wiState === "com.ibm.team.workitem.defectWorkflow.state.s1" ) {
return wiTechLead;
} //type = defect
else
return wiOwner;
}
});
})();
2 other answers
![](http://jazz.net/_images/myphoto/8771a2a070a5b6d96e917a60ff3dd48f.jpg)
dojo.provide("org.example.CalculatedOwner");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var CalculatedOwner= dojo.declare("org.example.CalculatedOwner", null, {
getValue: function(attributeId, workItem, configuration) {
console.log("Test");
return workItem.getValue(com.wiley.workitem.attribute.assignedBA);
}
});
})();
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var CalculatedOwner= dojo.declare("org.example.CalculatedOwner", null, {
getValue: function(attributeId, workItem, configuration) {
console.log("Test");
if (workItem.getValue(WorkItemAttributes.TYPE) === "defect" && workItem.getValue(WorkItemAttributes.STATE) === "com.wiley.workitem.defectWorkflow.state.s1")
return workItem.getValue(com.wiley.workitem.attribute.assignedBA);
}
});
})();
![](http://jazz.net/_images/myphoto/8771a2a070a5b6d96e917a60ff3dd48f.jpg)
Thanks a lot susan .. Appreciate your help .
BTW is it also possible to update the Subscriber list with the assignees Like as soon as owned by is Tech lead he should also get added to Subscriber list automatically .
Thanks
+Navneet
BTW is it also possible to update the Subscriber list with the assignees Like as soon as owned by is Tech lead he should also get added to Subscriber list automatically .
Thanks
+Navneet
Comments
![](http://jazz.net/_images/myphoto/e5e63d5878217b64611c1df9401b7cd3.jpg)
As mentioned in your other question, the only way to access the subscriber list is using Java API. JavaScript does not allow to access and manipulate the data as far as I can tell. This has been discussed on this forum already.
You could potentially try to access the user list in the attribute, but you can not add them to the subscriber list as far as I can tell.
Comments
Susan Hanson
Oct 03 '14, 7:41 a.m.What does your javascript look like now? When you get the value of the attribute, what value do you get back?