It's all about the answers!

Ask a question

Is it possible to define a default text for description of workitem type Defect?


Christian Winkler (1321623) | asked Nov 13 '14, 8:04 a.m.
Hallo!

I saw that JAZZ.net is using a default text in the description field dependent on the worktiem type.
For example, if I crete a defect, the description is prefilled with

"What steps will reproduce the problem?
1.
2.
3.
..."

A different description is shown, if a create a new Maintenace Item.
"Maintenance Item Guidelines
    1. How to use this work item:
..."
(Link to it)

I tried to configure this in our RTC, but the default text was set to all workitem types.

How can I configure it as it is in JAZZ.net?

Thanks!
Christian


Accepted answer


permanent link
Kot T. (1.5k11319) | answered Nov 13 '14, 2:40 p.m.
JAZZ DEVELOPER
Instead of using the script-base default value, you can also create multi-line text default values and map them to each work item type. See https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Default_values. This requires more default values to be created and maintained, but it's another option to consider.

I also attach a sample script below. The script assumes the ID of defect work item type to be 'defect'. The script is based on the skeleton provided in the 'Script-based default value' section in the jazz.net wiki link that Dinesh posted above. To create a script-based default value and use it, see https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Using_scripts_for_attribute_cust

//========== SAMPLE SCRIPT-BASE DEFAULT VALUE ==========
dojo.provide("com.example.common.MyClass");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
   
    dojo.declare("com.example.common.MyClass", null, {
    getDefaultValue: function(attribute, workItem, configuration) {
     
        var WorkItemType= workItem.getValue(WorkItemAttributes.TYPE);
        var DEFECT_DESC= "Defect Description Line 1\n\
Defect Description Line 2"
        var OTHER_DESC= "Other Description Line 1\n\
Other Description Line 2"

            if (WorkItemType == "defect") {
                return DEFECT_DESC;
            }
           
            return OTHER_DESC; 
    }  
});
})();

Christian Winkler selected this answer as the correct answer

Comments
Christian Winkler commented Nov 14 '14, 8:43 a.m.

Thanks Kot!
Your script worked for me.

But I couldn't realize your first idea.
As I created a multi-line text default values I couldn't add it to a Mutli-line HTML field like description.
And it wasn't possible to make it only for ONE workitem type.
Is it possible somehow differnt?


Kot T. commented Nov 14 '14, 11:39 a.m.
JAZZ DEVELOPER

That could be because Description is a built-in attribute, which is shared across multiple work item types in the project area. Per the note in the attribute's editor, modifying a built-in attribute will affect all WI types in the project.

You can create a custom description attribute of 'Large HTML' type for each work item type. Considering the number of custom attributes and default values that you have to create and maintain, the script-based default value maybe more efficient solution in this case.



Christian Winkler commented Nov 19 '14, 3:21 a.m.

Hello Kot!
Yes, I knew that it would be possible with a new field, but didn't understand that you meant this.
This would lead to two different descriptions: task-description would be in description and defect-description would be in description_defect.  This will lead to too much confusion.

But can you help me again with the script-base stuff:
Is it possible to format that return-text? So that it is shown bold and/or italic?

Thanks again.
Christian

One other answer



permanent link
Dinesh Kumar B (4.1k413) | answered Nov 13 '14, 8:31 a.m.
JAZZ DEVELOPER
have you explore the "Script Based Default Value" which seems more appropriate to me...

in the script, you could check for the workitem's TYPE (workItem.getValue(WorkItemAttributes.TYPE);) and return a different value accordingly. 

more on script based default could be found here : https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_based_default_values

hope it helps.

Comments
Christian Winkler commented Nov 13 '14, 10:38 a.m.

Hello Dinesh,

I need some more help. I looked for a tutorial, but can't find. Do you know something?
How do I set that the default value is set before workitem initialization?

Christian


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.