It's all about the answers!

Ask a question

How can I return an enumeration value to a calculated value using javascript?

Janet Charbonneau (852754) | asked Oct 24 '19, 1:07 p.m.
I have an attribute called Attention Flag which is an enumeration that contains "Reopened" and "Test Failed" as values in the enumeration list.  I would like to have that attribute as read only and calculate the value based on other attributes using Javascript.  I have tried using

return "Reopened"


return "Test Failed"

Both of these lines will properly return the value, but I get a warning red "x" flag on the attribute with the message "The selected value is not applicable."  It does not show the corresponding enumeration value with the associated icon.  I want it to show the enumeration value with the icon, not an error message.  Is there a way to return a value that will be one of the valid values in the enumeration list?

One answer

permanent link
Ian Wark (79713551) | answered Oct 24 '19, 8:49 p.m.
I think you need to use the name of the literal. Check in the configuration source. It should have a name like "myenumeration.literal.l10";

Then you can do some thing like
return "myenumeration.literal.l10";

See this document under section "Working with Enumerations":

Ralph Schoon commented Oct 25 '19, 2:39 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER tries to explain a lot of these questions in the last lab. 

Janet Charbonneau commented Oct 26 '19, 7:13 p.m.
Ian, I have tried

return "attentionflagenumeration.literal.14";

and it just returns


It doesn't recognize it as one of the enumeration entries.

Ralph, I looked into that last lab, but maybe I missed something.  I will research those further.  Thanks.

Ralph Schoon commented Oct 28 '19, 6:34 a.m. | edited Oct 28 '19, 7:12 a.m.
Hi Janet.

Note, I would suggest to develop attribute customization on test systems and not on the production system. 

There are possible strategies to proceed.

  1. Try using the debugger, to see what goes on.
  2. Check the logs for an error message see the Process Enactment Workshop to find the log to look into.
  3. Use the AttributeValueAnalyzer from the Process Enactment Workshop to understand the enumeration literal values you get with getValue(), especially for your attribute. These are the values you want to set. You should be able to find them in the project area administration, but somehow something seems to be not right. 
  4. Make the target attribute not read only and check if that changes anything. 

Ian Wark commented Oct 28 '19, 11:39 p.m.
When I do attribute customization, I generally have a bunch of logging in place, as Ralph suggests. For example, you can use something like this:
console.log("My message");
See this URL too for ideas to debug your Javascript:

Your answer

Register or 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.