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

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

Hello, I want to copy ID to a custom attribute automatically if it is empty.
How can I achieve the above?

0 votes


Accepted answer

Permanent link
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

2 votes

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

Question asked: Sep 01 '15, 12:09 a.m.

Question was seen: 2,210 times

Last updated: Sep 01 '15, 12:23 a.m.

Confirmation Cancel Confirm