It's all about the answers!

Ask a question

Automatically Changing "Project Area" for a workit


VK L (8177132159) | asked May 08 '12, 11:59 a.m.
Hi All,
Whenever a particular workitem type is created, i want to map it to a specific project area so that it is captured in a single project. Is this possible using API? How can this be achieved?

Thanks

10 answers



permanent link
Ralph Schoon (57.1k23642) | answered May 09 '12, 4:01 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Work item types are always bound to the project area. So, if you only provide that specific type to the project area where it is supposed to be created in, you don't need to extend RTC.

Otherwise I think you could try using a follow up Action. I assume you could look up the code to move a work item to another project area. I assume you would have to recreate the work item in the target project area, map all attribute values and set them. Then delete the old work item. Hopefully you have all the required attributes available.

I might also just not know if there is a simpler solution. I found, moving work items across project or server boundaries is not a trivial task. I tried and had to pause due to my schedule. If you try, I would be really interested in the solution.

permanent link
VK L (8177132159) | answered May 09 '12, 6:58 a.m.
Thanks. I will try it out.

Another requirement is that i want to populate attributes based on the Value chosen in the "Type" drop-down say. This is mainly to avoid creating multiple WI Types and corresponding presentation layouts - just want to consolidate all similar ones in a single type. Say for eg: Common Change request template for all teams

Thanks

Work item types are always bound to the project area. So, if you only provide that specific type to the project area where it is supposed to be created in, you don't need to extend RTC.

Otherwise I think you could try using a follow up Action. I assume you could look up the code to move a work item to another project area. I assume you would have to recreate the work item in the target project area, map all attribute values and set them. Then delete the old work item. Hopefully you have all the required attributes available.

I might also just not know if there is a simpler solution. I found, moving work items across project or server boundaries is not a trivial task. I tried and had to pause due to my schedule. If you try, I would be really interested in the solution.

permanent link
Ralph Schoon (57.1k23642) | answered May 09 '12, 7:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I already answered your other question as far as what I know in the respective post you did.

I have no solution at hand other than the article I mention.

In my opinion, if types are defined per project area you are creating more risk/effort with all the automation you try. If you try using process sharing and use the process of a central project area in other projects I can see some value in it, but I still think it might, unfortunately, probably be beyond what RTC can support today.

permanent link
VK L (8177132159) | answered May 09 '12, 7:54 a.m.
Thanks Ralph.

Regarding "Moving Workitems" to another project area, i tried setting the "Calculated value" script for "Project area" attribute - but it isnt getting trigerred.
However, the same script works for a custom attribute. I am able to modify "Project Area" attribute manually while creating a workitem though.

Any idea why it isnt triggering for existing attribute?

My script:
dojo.provide("com.ibm.workitems.providers.ProjArea");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.ibm.workitems.providers.ProjArea", null, {
getValue: function(attributeId, workItem, configuration) {

console.log("Entering ProjArea()");

var Proj = workItem.getValue(WorkItemAttributes.PROJECT_AREA);

console.log("Actual Project: " + Proj);

if (Proj == "_KiBckJj8EeGEm8UCzP_3BQ")
Proj = "_zjr_oGmHEeGqjsFAsoleXA";
console.log("Modified Project: " + Proj);
return Proj;
}
});
})();

The 2 values that are compared and assigned are the UUIDs of existing projects.

Thanks.

permanent link
Ralph Schoon (57.1k23642) | answered May 09 '12, 8:23 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
That is because of what i tried to explain above. You can not just change the project area attribute. I don't have time to debug into it, but my best guess is, it is an internal, read only, derived attribute.

A Story in project area 1 is a different entity from a story in project area 2. Even if the type name is the same, they are completely different. the work items live in their project area. All values are derived from it. If you want to move it you have to do more than just change the project area. You would have to map each attribute value for categories, enumerations and what not and try to get the value that lives in the other project area. I think you have to do a deep copy.

There is a special Copy or move work item tool in the RTC client that does this. It took some time to get it done, so I assume it is not trivial.

permanent link
VK L (8177132159) | answered May 09 '12, 11:04 a.m.
I made the attribute read-only and then performed my action as stated previously. I am able to change the "Project area" attribute while creating the work-item -> and this does a move WI operation directly and i could see the WI in project-area2. So just curious why it isnt happening through the script - It is not even getting triggered.

permanent link
Ralph Schoon (57.1k23642) | answered May 09 '12, 11:57 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I made the attribute read-only and then performed my action as stated previously. I am able to change the "Project area" attribute while creating the work-item -> and this does a move WI operation directly and i could see the WI in project-area2. So just curious why it isnt happening through the script - It is not even getting triggered.


I would not have believed that this would be possible and I am not sure about the effect it will have or if it will generally work (e.g. what happens if the selected category is not configured in the other project area).

The scripting is experimental and as described on the wiki has only limited support for attributes (there is a list) and attribute types (there is a table of what is supported). In general text or int attributes work.

Contributor and other types tend not to work. They return the UID, but setting does not work, at least I don't know anyone who had luck with them. I would assume it won't work. If there is no other attribute customization option for project areas I am pessimistic.

permanent link
VK L (8177132159) | answered May 10 '12, 3:41 a.m.
The custom attribute that i created was of type "Project area" - same as the existing project area - and i could successfully change its value. So, i dont think its a problem with the attribute type...

permanent link
Ralph Schoon (57.1k23642) | answered May 10 '12, 5:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi,

I can't tell if it would work, without deep investigation.

Just having an attribute with a project area as value has absolutely nothing to do with the work item being owned by that project area. It is just a value.

The whole definition including custom attributes and custom and enumeration values is, as far as I am aware bound to the project area that defines the type. A work item created in one project area could not necessarily exist in another project area or have the same values there.

The type might not exist, if it does, the custom attributes might not exist or enumeration values might not exist or have different literal values. This is why I believe just changing the project area value won't work and a deep copy or something else is needed. Maybe someone else knows better.

permanent link
VK L (8177132159) | answered May 10 '12, 9:25 p.m.
The pre-requisite for my requirement is that the similar template will exist in the other project area as well where i am trying to move it to. Thats why i am just trying to change the project area alone - and this should happen through a script or plugin for all workitems of a similar type.
Both my project areas contain the same template with the same set of fields.

Thanks.

Your answer


Register or to post your answer.