Is it possible to define a default text for description of workitem type Defect?
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
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;
}
});
})();
Comments
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?
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.
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
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.