How to use javascript to add tag
I am trying to "save" Pland for history using Tags.
I am trying to add tag for every "Planed for" value using attribute customisation -> Script base Value set.
my script is:
dojo.provide("org.myorg.CopyPlanForToTag");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var MyTags= [];
dojo.declare("org.orbotech.CopyPlanForToTag", null, {
getValue: function(attributeId, workItem, configuration) {
MyTags.push(workItem.getValue(WorkItemAttributes.PLANNED_FOR));
return MyTags;
}
});
})();
I set the Tag to use the script & add Planed for as dependencies.
I dont get any value in the Tag.
can I set the Tag this way?
is there another way do add tag?
thank you
One answer
1. The "Tags" attribute appears to be expecting a "collection", not an "array". I found it out in the error message that I got.
2. workItem.getValue(WorkItemAttributes.PLANNED_FOR) returns the internal Id, not the label such as "Release 1.0".
3. Tags only allow a single word, and the enumeration label needs to be converted before passing on as a tag.
Comments
The JavaScript API provides workItem.getValue() (provides the ID of the item for more complex items) and workItem.getLabel() which describes the display value.
thank you for your answers.
since it become more complicated then I thought, I use the SDK to solved it.
Am I right, you wanted to change a Workitem State e.g. from "new" to "Planned for" or did you just wanna set a tag?