Need help with calculated value for owner
I have an issue/defect work item that needs to be "owned" by different people at different stages of the process. When it is new, it needs to be owned by a triage person, when working it needs to be owned by a developer, and when validating it needs to be owned by a tester.
I have created separate custom fields for each of these three "owners" and used role-based user list value set to allow the work item editor to only select people on the team that have that role, but as these three fields are not the OWNER field, when you add a user there, they do not get automatically subscribed to the work item.
I have tried to create a calculated value script for the owner field, but because my three fields are custom, I can't get the value from them in the script to set it into the owner field.
Does anyone have any suggestions for making this work? I can either try to get the owner field to change with a calculated value script that updates or I can try to work on setting the subscriber field to update when I set any of my three fields.
Note that I am in a shared production server environment, so I would not be allowed to deploy a server side customization to make this work.
Any other ideas of how to make this work outside of attribute customization would be helpful.
Thanks
|
Accepted answer
Ralph Schoon (63.4k●3●36●46)
| answered Jun 27 '13, 8:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Jun 27 '13, 8:14 a.m.
If you need more control in your attribute customization e.g. access to process areas and user data, consider using a Java based custom provider. Here are some examples that show especially the user and process API: http://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/
John Goodson selected this answer as the correct answer
|
5 other answers
why can't u get the value from the custom fields? workitem.getvalue('custom-field-id') should work.
(my assumption is those fields are contributors). lists are a pain in the rear.. workitem.getlabel('custom-field-id') for contributor will give u the text name of the person i learned last week. so the conditional provider extension should work fine. set it on Owner, and calculate away |
Thanks for the help, unfortunately, it is still not doing what I want. Here is the script I am working on. If anyone has ANY suggestions, I would be happy to get them.. I have tried both getvalue and getlabel and get the same results.
Also, I can't seem to figure out the console.log function, I added the ?debug=true to the web URL, but I never see the log messages in my JavaScript console (tried Chrome and Firefox)
dojo.provide("essi.calculated.CalculatedOwner");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("com.ibm.team.workitem.api.common.Severity");
dojo.require("com.ibm.team.workitem.api.common.Status");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var Status = com.ibm.team.workitem.api.common.Status;
var triage = workitem.getvalue('com.ibm.team.workitem.attributes.issuetriage');
var resolver = workitem.getvalue('com.ibm.team.workitem.attributes.resolutionowner');
var tracker = workitem.getvalue('com.ibm.team.workitem.attributes.issuetracker');
var creator = workitem.getvalue(WorkItemAttributes.CREATOR);
var owner = workItem.getValue(WorkItemAttributes.OWNER);
var CalculatedOwner= dojo.declare("essi.calculated.CalculatedOwner", null, {
getValue: function(attributeId, workItem, configuration) {
console.log("Starting Calculate Owner");
console.log("Triage");
console.log(triage);
console.log("Creator");
console.log(creator);
if (workItem.getValue(WorkItemAttributes.TYPE) === "issue" && workItem.getValue(WorkItemAttributes.STATE) === "1") {
return triage;
} else if (workItem.getValue(WorkItemAttributes.TYPE) === "issue" && workItem.getValue(WorkItemAttributes.STATE) === "2") {
return resolver;
} else if (workItem.getValue(WorkItemAttributes.TYPE) === "issue" && workItem.getValue(WorkItemAttributes.STATE) === "4") {
return tracker;
} else if (workItem.getValue(WorkItemAttributes.TYPE) === "issue" && workItem.getValue(WorkItemAttributes.STATE) === "6") {
return triage;
} else if (workItem.getValue(WorkItemAttributes.TYPE) === "issue" && workItem.getValue(WorkItemAttributes.STATE) === "7") {
return resolver;
} else if (workItem.getValue(WorkItemAttributes.TYPE) === "issue" && workItem.getValue(WorkItemAttributes.STATE) === "8") {
return creator;
} else if (workItem.getValue(WorkItemAttributes.TYPE) === "issue" && workItem.getValue(WorkItemAttributes.STATE) === "9") {
return owner;
} else if (workItem.getValue(WorkItemAttributes.TYPE) === "issue" && workItem.getValue(WorkItemAttributes.STATE) === "10") {
return creator;
} else if (workItem.getValue(WorkItemAttributes.TYPE) === "issue" && workItem.getValue(WorkItemAttributes.STATE) === "11") {
return triage;
} else if (workItem.getValue(WorkItemAttributes.TYPE) === "issue" && workItem.getValue(WorkItemAttributes.STATE) === "12") {
return resolver;
} else if (workItem.getValue(WorkItemAttributes.TYPE) === "issue" && workItem.getValue(WorkItemAttributes.STATE) === "13") {
return tracker;
} else if (workItem.getValue(WorkItemAttributes.TYPE) === "issue" && workItem.getValue(WorkItemAttributes.STATE) === "14") {
return resolver;
} else if (workItem.getValue(WorkItemAttributes.TYPE) === "issue" && workItem.getValue(WorkItemAttributes.STATE) === "15") {
return triage;
} else {
return owner;
}
}
});
})();
Comments
Ralph Schoon
commented May 05 '13, 4:18 a.m.
| edited May 05 '13, 4:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You schoold consider reading https://jazz.net/library/article/1093 lab 5. Please be aware the logs are not the CCM log but the eclipse logs on client or server. The workshop explains where to find them, it also explains what you can or can not do with attribute types such as contributor. If you want to set such values, you have to return the user uuid which you get with getValue. |
John,
Are you getting a specific error with this script or is it just that nothing happens when you modify a work item and save? For the console.log output I always use the Eclipse Clients error view. For the web I would probably try using Firebug but can't remember if I have and it worked in the past. If you added the script to the Owner attribute did you make it dependent on State and Type? |
why are u doing these
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var Status = com.ibm.team.workitem.api.common.Status;
var triage = workitem.getvalue('com.ibm.team.workitem.attributes.issuetriage');
var resolver = workitem.getvalue('com.ibm.team.workitem.attributes.resolutionowner');
var tracker = workitem.getvalue('com.ibm.team.workitem.attributes.issuetracker');
var creator = workitem.getvalue(WorkItemAttributes.CREATOR);
var owner = workItem.getValue(WorkItemAttributes.OWNER);
outside the actual function call? doesn't that do these calls only once, when the class is loaded? not every time the getvalue function is called getValue: function(attributeId, workItem, configuration) { I look in the server/logs/ccm.log for the messages (for the eclipse client) |
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.
Comments
Have you considered giving each "owner" either their own work-item, or if you want a lighter weight approach, give the other owner's "approvals" indicating they've done their part of the work?