Calculate work item 'owned by' by 'found in'
Hi,
I am attempting to set the 'Owned by' field based on the category selected.
Here is my javascript
dojo.provide("com.ibm.team.workitem.attribute.owner");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.ibm.team.workitem.attribute.owner", null, {
getValue: function(workitem) {
var catagory= workItem.getValue(WorkItemAttributes.FOUND_IN);
if ((catagory === "Product 1.9.0.2")) {
return "xxy@us.ibm.com";
} else if ((catagory === "Product 1.9.0.1")) {
else return "xxyy@us.ibm.com";
} else if ((severity === "Product 1.9.0.0")) {
else return "xxyyy@us.ibm.com";
} else {
return "no_idea@us.ibm.com";
}
}
});
})();
|
One answer
Next time you should make your post as a question, otherwise no one knows the purpose that you are sharing your script to others.
Apparently your script does not work, as there are so many problems in such a short script. I list the most obvious ones below. 1. Avoid using a class name such as "com.ibm.*". You may introduce conflicts by doing so. You can use the one suggested by the sample code, such as "com.example.ValueProvider.OwnerFound", if you don't have a better idea. 2. JavaScript is case-sensitive. You have both "workitem" and "workItem" in your script and latter will be treated as "undefined". 3. Pay attention when you copy codes from elsewhere. You have two "else return" within the "else if" block which makes no sense at all. Also the variable "severity" just appears from nowhere and should have been "category". 4. The function workItem.getValue() returns the ID of the attribute, such as "_-O6vMIPsEeSNXIoymcU8qg", not the label. If you want the readable form, use workItem.getLabel() function instead. 5. Similar to the previous point, the value provider should return an ID, such as "_o1U7dYPsEeSypNOpTJQ02A" (identifying a user), not an email address, to the "owner" attribute. I strongly suggest you read through the attribute customization wiki page, and learn how to use Chrome and Firefox to debug JavaScript. https://jazz.net/wiki/bin/view/Main/AttributeCustomization https://jazz.net/library/article/1003 https://jazz.net/library/article/1360 Comments
jeff mccallum
commented Jul 23 '15, 5:28 p.m.
Hi Donald,
Thank you for the help.
Output from my debug
Problems executing value provider for {0}: workitem is not defined. ReferenceError: workitem is not defined
at dojo.declare.getValue (test.js:15:23)
at dojo.declare.getValue (https://cmccm.usca.ibm.com:9443/ccm/web/_js/?exclude=B&include=com.ibm.team…rnal.page.WorkItemPageView&ss=Gw93y&_proxyURL=%2Fccm&locale=en-us:29634:56)
at dojo.declare._handleValueWhenDependencyChanged (https://cmccm.usca.ibm.com:9443/ccm/web/_js/?exclude=B&include=com.ibm.team…rnal.page.WorkItemPageView&ss=Gw93y&_proxyURL=%2Fccm&locale=en-us:29807:19)
at null.<anonymous> (https://cmccm.usca.ibm.com:9443/ccm/web/_js/?exclude=B&include=com.ibm.team…ernal.page.WorkItemPageView&ss=Gw93y&_proxyURL=%2Fccm&locale=en-us:29847:6)
jeff mccallum
commented Jul 23 '15, 5:30 p.m.
And my current js
dojo.provide("com.example.ValueProvider.OwnerFound");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); (function() { var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes; dojo.declare("com.example.ValueProvider.OwnerFound", null, { getValue: function(WorkItemAttributes) { var catagory= workItem.getValue(WorkItemAttributes.FOUND_IN); if ((catagory === "Product 4.9.0.2")) { return "xxy@us.ibm.com"; } else { return "no_idea@us.ibm.com"; } } }); })(); Do not change the signature of the call back function. Start with the sample code by using the "fill in example" link first and build you code around it, if you don't really know how the code should look like.
|
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.