It's all about the answers!

Ask a question

Issue in writing script for Dynamic read only attribute using customized attribute


Sachin Nairy (5111320) | asked Jul 23 '12, 4:42 a.m.

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

    }

});

})();


Comments
Millard Ellingsworth commented Jul 23 '12, 8:18 p.m.
FORUM ADMINISTRATOR / JAZZ DEVELOPER

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.

Accepted answer


permanent link
Gabriel Enriquez (3463) | answered Jul 24 '12, 1:32 a.m.
JAZZ DEVELOPER
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


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.