Enumerations and Calculated Values Java script
Hi
I have a enumeration in a work item defined as this: <enumeration attributeTypeId="ConsultingTimesheet.ConsultedDepartmentorArea2" name="ConsultingTimesheet.ConsultedDepartmentorArea2">This enumeration is then used in a work item attribute with id: enumeration.ConsultingTimesheet.ConsultedDepartmentorArea However, when I execute this call in the Calculated value script: var summary3 = workItem.getValue("enumeration.ConsultingTimesheet.ConsultedDepartmentorArea");It is always returning the default value ConsultingTimesheet.ConsultedDepartmentorArea2.literal.l2In the log file, no matter what value I select in the enumeration in the work item I have created. So it seems to always be returning the default value for the enumeration rather than the selected value. Does any one know what I may be doing wrong in the script ? Also, if I try and use "workitem.getLabel" to get the label value for the enumeration, for example, var summary3 = workItem.getLabel("ConsultingTimesheet.ConsultedDepartmentorArea2.literal.l2"); It throws an exception. Any ideas what I could be doing wrong ? Thanks in advance Rob |
2 answers
Ralph Schoon (63.5k●3●36●46)
| answered Nov 06 '13, 2:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Rob,
you can not get the label from an enumeration literal as you do above. workItem.getLabel(attributeID) only works for attribute ID's and gets the label of the value of said attribute. I have been able to get the literals and labels of enumerations. I have described this in Lab 5 of https://jazz.net/library/article/1093 and I would suggest you have a look at the 'Spy' script and the lab in total. The examples should help you to understand the basics and there is a section explaining the limitations of the JavaScript API. Another thought is, if you create a calculated value script, for which attribute is that script above configured? If it is for enumeration.ConsultingTimesheet.ConsultedDepartmentorArea then, I think it would always return the default. If you want to calculate the value of an attribute from its own value, there are issues to be expected. In general calculated attributes should be read only and calculated from other attribute values. |
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.