It's all about the answers!

Ask a question

Attribute customization on custom work items


vikrant kamble (1322996) | asked Jan 15 '16, 6:27 a.m.
 Hi All,
below is script which validate defect work item. When work item is in Resolved state its resolution should be "Fixed"

dojo.provide("org.example.RestrictResolutionState");

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

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

var RestrictResolutionState= dojo.declare("org.example.RestrictResolutionState", null, 

{
   validate: function(attributeId, workItem, configuration) 

{
if (workItem.getValue(WorkItemAttributes.TYPE) === "defect" && workItem.getValue(WorkItemAttributes.STATE) === "3") 
{
  
if (workItem.getValue(WorkItemAttributes.RESOLUTION) === "1") 
{
return Status.OK_STATUS;
else 
{

var severity= configuration.getChild("parameters").getStringDefault("severity", Severity.ERROR.name);

var message= configuration.getChild("parameters").getStringDefault("message", "");

return new Status(Severity[severity], message);
               
}
} else {
return Status.OK_STATUS;
}
}
});
})();

In this script id 3 is for resolved state and id 1 is for "Fixed" resolution.

I have custom work item of type "feature". "feature" is its Id. Its editor presentation is same as that of defect.
as we are using numbers in built in work item types, it does not seem to be working on custom work item.
I have state as resolved in custom work item and resolution as "feature implemented".
Both number as well as string value of state is not working in the script.
Is there any other way to access state and resolution of custom work item.

One answer



permanent link
Ralph Schoon (63.1k33645) | answered Jan 15 '16, 6:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
1. Print the values into the log to figure what you are getting. Especially state id's have two different forms due to historical reasons e.g. s1 vs 1.
2. Attribute customization works for all work item types that have the attribute this is configured for, so you will have to determine the type as well.
3. I am not sure if attribute validation will help you with what you want to do.


See
  lab 5 for an attribute spy script you can use to print what you get into the description.

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.