How can I return an enumeration value to a calculated value using javascript?
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"
or
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
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":
Comments
https://jazz.net/library/article/1093 tries to explain a lot of these questions in the last lab.
Ian, I have tried
return "attentionflagenumeration.literal.14";
and it just returns
attentionflagenumeration.literal.14
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.
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.
- Try using the debugger, to see what goes on.
- Check the logs for an error message see the Process Enactment Workshop to find the log to look into.
- 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.
- Make the target attribute not read only and check if that changes anything.
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: