It's all about the answers!

Ask a question

How to do attribute customization to clear Description field


Ian Wark (79713553) | asked Feb 11 '13, 8:08 p.m.
We have been viewing the wiki page below to figure out how to do a particular customization.
https://jazz.net/wiki/bin/view/Main/AttributeCustomization

Our requirement is to add a Tag to a workitem called "clean" and after focus is lost clear the Description field of workitem. We copied the example under Script Based Value Set about setting the Severity enumeration, because it looked like we could also achieve what we wanted with this. Using this we could add the "clean" Tag to workitem and after losing focus it adjusts the contents of the Severity enumeration. Only problem is how can we add the Tag and clear the contents of the Description field. I don't think we can use array type for this field, which Value Sets must use. We couldn't figure out what other category we might use. How should we write our script? Here is roughly what we have:

dojo.provide("org.example.workitems.providers.SeverityTagValueSet");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.string");

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

dojo.declare("org.example.workitems.providers.SeverityTagValueSet", null, {

    getValueSet: function(attributeId, workItem, configuration) {
   
        var tags= workItem.getValue(WorkItemAttributes.TAGS);

        var result= [];
       
        if (tags.indexOf("clear") != -1) {
            result.push("");
        }
       
        return result;
    }
});
})();

Here is the example we were copying:

dojo.provide("org.example.workitems.providers.SeverityTagValueSet");

dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.string");

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

dojo.declare("org.example.workitems.providers.SeverityTagValueSet", null, {

    getValueSet: function(attributeId, workItem, configuration) {
    
        var tags= workItem.getValue(WorkItemAttributes.TAGS);
        var severityOptions= [];
        
        if (tags.indexOf("important") === -1) {
            severityOptions.push("severity.literal.l1"); // Unclassified
            severityOptions.push("severity.literal.l2"); // Minor
            severityOptions.push("severity.literal.l3"); // Normal
        }
        
        severityOptions.push("severity.literal.l4"); // Major
        severityOptions.push("severity.literal.l5"); // Critical
        severityOptions.push("severity.literal.l6"); // Blocker

        return severityOptions;
    }
});
})();

Accepted answer


permanent link
Ralph Schoon (63.6k33646) | answered Feb 13 '13, 4:41 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
 In addition to Millard's great and valid answer you might want to look into https://jazz.net/library/article/1093 lab 5 for inspirations.
Ian Wark selected this answer as the correct answer

Comments
Ralph Schoon commented Feb 13 '13, 4:43 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

There is an example that sets the description and prints debug output, so you might be able to achieve your goal. 


Ian Wark commented Feb 14 '13, 12:06 a.m. | edited Feb 18 '13, 7:37 p.m.

Thank you both for your answers. The information is quite helpful.


Ralph Schoon commented Feb 19 '13, 3:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Ian, please consider accepting one of the answers (for example Millard's) if they solved your problem. This will help others searching the forums.

One other answer



permanent link
Millard Ellingsworth (2.5k12431) | answered Feb 12 '13, 7:21 p.m.
FORUM ADMINISTRATOR / JAZZ DEVELOPER
If you have been reviewing that article, the first thing to point out is the list of attribute types that can be safely read by and returned from scripts:
  • Short String
  • Medium String
  • Large String
  • Integer
  • Long
  • Decimal
  • Boolean
  • Timestamp
  • limited support for Enumerations
  • limited support for Items
which does not include Large HTML attribute types. Since Description has a Large HTML attribute type, it may not be compatible with scripting. There have been some similar questions relating to Contributors -- another type not supported per the article.

That said, on the chance that the documentation didn't mention Large HTML and should have, the next issue is how you are triggering and handling the update.

I'm certain that returning a value set is not what you want. You need a value to replace the current value of Description. A calculated value script is possibly the way to go here, except that, from the document: An attribute configured with a calculated value customization should use a read-only presentation.

You probably don't want a read-only Description. You could violate the suggestion (which I don't necessarily recommend), just be careful that when the tag you are watching for is not present, that you return the value of the Description unchanged. Also beware of the timing of calculated value script execution (you'll need to make Description dependent on Tags if you want it cleared interactively).

Not all customizations work well as JavaScript-based ones. You may want to consider a Java-based customization.

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.