AttributeCustomization: Custom value
8 answers
have you looked into https://jazz.net/library/article/1093 Lab 5?
You need to enable scripting too, before it will work, see the workshop above. Another thing is that you should set your calculated value attribute to read only (not required). Otherwise, without looking at the logs, I would assume your script to work.
have you looked into https://jazz.net/library/article/1093 Lab 5? I ask this again, because several of your questions are answered there.
I typically use
var estimate=parseInt(workItem.getValue(WorkItemAttributes.ESTIMATE));To convert from the string representation to something that is an integer. All examples in https://jazz.net/library/article/1093 that do calculations do that. You can use whatever JavaScript provides to do that. I am not a Dojo expert, but there are also DoJo methods to do these conversions that I have seen used in this forum.
You can fill enumerations from scripts. You have to pass back the enumeration literal ID.
I don't think you can get the value of an attribute and use that to compute a default value. Default values are created during creation of the work item. Only very few attributes have a value already at that point in time. So I am not sure this is possible. Probably depends on the input attributes and what you want to do.
All I have used so far in this area is described in 5.2.1 Total Cost Calculated Value. It uses parseInt() as described above to get a number from the string. https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript shows a bit more information on types supported. As far as I can tell you need to convert the values to something useful, probably because JavaScript is unfortunately untyped.
Comments
Milan, so far I was able to proof that in most of the cases, where I ran into problems, I was doing something wrong. There are some defects against Scripting however and we ran into something funny recently where we had different behavior on the Eclipse Client versus the Web UI.
Having said that, I have not seen things fixing themselves. One thing to note is, if you test scripting, close the work item and reopen it after changing the script, otherwise the script is cached and won't reload.
I honestly don't understand what you are asking above. The script also basically passes the input value back into the attribute and does noting with it. So I think I am stuck.
Hi Ralph,
Hi, as I already tried to express in earlier posts, for Enumerations you have to pass the enumeration literals as string. You have to look up the enumeration literals in the Process Configuration Source, or use a script to spy at the labels and values.
The script below defaults the Risk attribute to medium.
/*********** * Licensed Materials - Property of IBM * (c) Copyright IBM Corporation 2011. All Rights Reserved. * * Note to U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule * Contract with IBM Corp. ***********/ dojo.provide("com.example.DefaultValueProvider");(function() { dojo.declare("com.example.DefaultValueProvider", null, {
getDefaultValue: function(attribute, workItem, configuration) { return "Risk.literal.l3" } });
})();