How to do attribute customization to clear Description field
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
Ralph Schoon (63.6k●3●36●46)
| 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 There is an example that sets the description and prints debug output, so you might be able to achieve your goal. Thank you both for your answers. The information is quite helpful. 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
Millard Ellingsworth (2.5k●1●24●31)
| 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:
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
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.