It's all about the answers!

Ask a question

How to copy ID to a custom attribute autommatically if it is empty


Masahiro Mizogami (132) | asked Sep 01 '15, 12:09 a.m.
Hello, I want to copy ID to a custom attribute automatically if it is empty.
How can I achieve the above?

Accepted answer


permanent link
Kohji Ohsawa (5951310) | answered Sep 01 '15, 12:23 a.m.
JAZZ DEVELOPER
Hi Mizogami-san,

I think it can be done with using a script based attribute customization like below. When you create a new workitem, I would assume the custom attribute should be -1 or 0 so that the script returns ID. If it is not empty, it simply returns the original value of the attribute. Hoping it would help you. Thank you. 

/* sample */
dojo.provide("com.example.ValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

   dojo.declare("com.example.ValueProvider", null, {

        getValue: function(attribute, workItem, configuration) {
var value = parseInt(workItem.getValue(attribute));
if (value < 1){
value = workItem.getValue(WorkItemAttributes.ID);
}
return value;
        }
    });
})();
Masahiro Mizogami selected this answer as the correct answer

Your answer


Register or 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.