It's all about the answers!

Ask a question

Need help with calculated value for owner


John Goodson (2158) | asked Apr 25 '13, 4:52 p.m.
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

Comments
Geoffrey Clemm commented Apr 26 '13, 1:06 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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?

Accepted answer


permanent link
Ralph Schoon (59.7k23643) | 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



permanent link
sam detweiler (12.5k6184201) | answered Apr 25 '13, 7:06 p.m.
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

permanent link
John Goodson (2158) | answered Apr 29 '13, 11:51 a.m.
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.


permanent link
Michael Walker (99214198157) | answered May 04 '13, 4:30 a.m.
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?

permanent link
sam detweiler (12.5k6184201) | answered May 04 '13, 8:25 a.m.
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)

permanent link
John Goodson (2158) | answered May 05 '13, 9:42 a.m.
 Thanks for the help everyone. This was my first foray into Script based attribute customization. I have made significant progress and I will share what I found here in the hopes of helping others.

I was trying to take the contributor name from a custom field and set it into the Owner field. 

I am on version 4.0.2 and this is not working fully. It will actually be fixed in 4.0.3 according to a defect I found (which I can't find now, but will post tomorrow). The defect states that when you attempt to use getValue from a custom contributor attribute it returns nothing. I found this myself by taking the getValue from a custom field and displaying it in a string attribute. When I did the same for a built-in contributor value like OWNER or CREATOR, I got the UUID of the contributor.

Now that's great it will be fixed in 4.0.3, but I wanted to try to get it working now.

I started to play with getLabel which does work on custom contributor fields, but it only returns the User name not the UUID value. Fortunately, I have a fairly limited set of team members using my workspace, so I created created a new string computed value attribute and read getLabel and then wrote a switch function to return the UUID of that member which I had previously looked up using my string attribute for getValue of OWNER and manually coded those into a script

Next, I re-did my Owner calculated value. Now I can read either the getValue or getLabel of my UUID field and get that information. If I set it into my owner field, it computed correctly and sets the owner.

So I am 90% there. The next thing that I tried was to write a switch in my Owner calculated value based on status. I have tried both getLabel and getValue from STATE, but I can't seem to get that switch to work, but I think it is just a minor issue that I haven't figured out since it should work. (I can see the correct values returned for STATE in another string attribute)

I found that the debugging functions were VERY hard to use. I am not sure what I am doing wrong, but I can't see the debug on the web client. (I did follow Lab 5 to the letter)  I do not have access to the server logs. I will see if my Eclipse client logs contain any debug. What I have found that was helpful was adding additional calculated value scripts to STRING attributes. By doing that with getValue and getLabel functions I was able to see what would be returned by each function for other attributes.

 

Comments
Ralph Schoon commented Jun 27 '13, 8:15 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

John,

I have switched to Chrome and the included developer tools, for debugging of scripts. I had the same issue with Firefox and Chrome just revealed the scripts without issues.

Your answer


Register or to post your answer.