Jazz Register Log in
Jazz Forum Welcome to the Jazz Community Forum

Welcome to the Jazz Community Forum

Connect and collaborate with IBM Engineering experts and users

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

    }

});

})();

0 votes

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.


Accepted answer

Permanent link
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

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,059

Question asked: Jul 23 '12, 4:42 a.m.

Question was seen: 3,335 times

Last updated: Jul 24 '12, 1:32 a.m.

Confirmation Cancel Confirm