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 (60.5k●3●36●43)
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. |