Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Attribute Customisation: Setting a Custom Attribute (enumerated) using a Calculated Value script

We have added a custom attribute ("Risk RAG") to the Risk work item. The attributed is an enumerated type with possible values of "Red", "Amber" and "Green". We are attempting to set the value using a script which utilizes the "Exposure" attribute. Here is the script code:
dojo.provide("risk.rag.ValueProvider");
(function() {
    dojo.declare("risk.rag.ValueProvider", null, {
        getValue: function(attribute, workItem, configuration) {
            var riskrag = "Unassigned";
            var exposure = 0;
            var redrag = 59;
            var amberrag = 17
            var greenrag = 1
            var exposure = workItem.getValue("com.ibm.team.workitem.workItemType.risk.exposure");
            if (exposure > redrag) {
                riskrag = "Red";
            } else {
                if(exposure > amberrag){
                    riskrag = "Amber";
                } else {
                    riskrag = "Green";
                }
            }                    
            return riskrag;
        }
    });
})();
When the attribute is displayed in the work item editor and error ("The selected value is not applicable") is displayed next to the attribute. I suspect that this is due the fact we have not assigned the enumerated literal correctly.
Please can you advise on how I retrieve and set the enumerated literal within the Calculated Value script.

Many thanks

0 votes



2 answers

Permanent link
what are the ID's of your enum values?  ID's are what u need to manipulate.

I don't know how to retrieve the enum value IDs via javascript.

0 votes


Permanent link
 Hello Ian,
you're correct. You should not use enum values labels (Red, Amber, ...)
but fully qualified id's (myenum.id.literal.l2, etc...)
See https://jazz.net/wiki/bin/view/Main/AttributeCustomization#WorkingWithEnums

To map id to label, check Project Area Source.

Hope it helps.
Eric

0 votes

Comments

Eric, many thanks for the pointer. Once I have the Id's how do I return the correct value?

how does he get the enum shape? literal id ='text string' so that his code is not dependent on the last time he manually read the process config source.

you return the id string (for example) 'com.ic.risk.exposure.enum.green'

ic= your initials

Thank you for the pointer. All now working.

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

Question asked: May 16 '14, 8:32 a.m.

Question was seen: 5,556 times

Last updated: May 16 '14, 11:48 a.m.

Confirmation Cancel Confirm