Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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 

0 votes



One answer

Permanent link
I have not been able to implement what you want to do but have found a few things that you need to take care of.
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.

1 vote

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?

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,019
× 152
× 24

Question asked: May 27 '14, 10:32 a.m.

Question was seen: 4,848 times

Last updated: Jul 08 '14, 5:02 a.m.

Confirmation Cancel Confirm