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:
Please can you advise on how I retrieve and set the enumerated literal within the Calculated Value script.
Many thanks
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
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