Issue in writing script for Dynamic read only attribute using customized attribute
Hi All,
I am facing issue in writing script for Dynamic read only attribute.
I created one enumeration “Project Type” with some values.
ID = Projecttype
Name = Project Type
Literal = Projecttype.literal.l2
I tried with example script which is working fine but it is not working for customized attribute
I got confused while passing the attribute ID, for built-in attribute we are passing com.ibm.team.workitem.api.common.WorkItemAttributes.PRIORITY
What about built in attribute?
Please help me to resolve this issue.
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#ScriptBasedNotes
Working Script:
dojo.provide("org.example.workitems.providers.FinishedCondition");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("org.example.workitems.providers.FinishedCondition", null, {
matches: function(workItem, configuration) {
var state= workItem.getValue(WorkItemAttributes.PRIORITY);
console.log(typeof(state))
return (state === "priority.literal.l11"); // High
}
});
})();
Not Working Script:
dojo.provide("org.example.workitems.providers.FinishedCondition");
dojo.require("Projecttype");
(function() {
dojo.declare("org.example.workitems.providers.FinishedCondition", null, {
matches: function(workItem, configuration) {
var type= workItem.getValue(Projecttype);
return (type === "Projecttype.literal.l2"); // Project
}
});
})();
|
Accepted answer
There is not need to use:
dojo.require("Projecttype"); Within the body of the function, to retrieve the label: workItem.getLabel("<attributeId>"); or to retrieve the id: workItem.getValue("<attributeId>"); Where: <attributeId> is the custom attribute ID of the work item type. -- Gabriel Enriquez, IBM Rational, Tracking & Planning Sachin Nairy selected this answer as the correct answer
|
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.
Comments
Have you debugged into the script? Is the value of your variable "type" getting set to a value you recognize? Since you need to pass in the ID value for the variable, you may need to put "Projecttype" in quotes -- I can't tell what the dojo.require("Projecttype") is doing as I can't see the contents of that file. In the comparable call in the working script, the dojo.require() loads a JavaScript file with a series of constant definitions that can be used in the getValue() call.