Attribute Customisation: Setting a Custom Attribute (enumerated) using a Calculated Value script
Ian Cuttriss (1●5●5)
| asked May 16 '14, 8:32 a.m.
edited May 16 '14, 10:23 a.m. by Ralph Schoon (63.6k●3●36●46)
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 |
2 answers
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. |
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
Comments
Ian Cuttriss
commented May 16 '14, 9:19 a.m.
Eric, many thanks for the pointer. Once I have the Id's how do I return the correct value?
sam detweiler
commented May 16 '14, 9:23 a.m.
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.
sam detweiler
commented May 16 '14, 9:31 a.m.
you return the id string (for example) 'com.ic.risk.exposure.enum.green'
Ian Cuttriss
commented May 16 '14, 11:48 a.m.
Thank you for the pointer. All now working.
|
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.