Attribute Customization: Can a Calculated Value use the contents of Checkbox Enumeration List without a save using JS?
We have a Calculated Value that reads another Checkbox Enumeration List. However, the Calculated Value will only show the correct value after the work item has been saved. Other fields do update the calculated field when they are modified without requiring a save.
In all cases, the necessary dependencies in the Types and Attributes GUI are configured. This pertains to JavaScript Calculated Values entered into the Attribute Customization GUI. Is there anyway for a Checkbox Enumeration List Presentation information to be available via a workItem.getValue() function in our scripts? |
4 answers
Millard Ellingsworth (2.5k●1●24●31)
| answered Oct 28 '13, 7:32 p.m.
FORUM ADMINISTRATOR / JAZZ DEVELOPER
Yes. Here's what I did to test, let me know if this does not map to your situation the way I think it does.
And the AndroidVersionNumber field updates immediately in the web ui whenever I click checkboxes in the AndroidVersion field.
Here's the script code:
dojo.provide("edu.millard.forumtest.ValueProvider");
Also from the same piece linked above, there are Web UI debugging tips that may be helpful (I used the debugger to investigate the array returned by the get call).
Comments
vishnudharan manivannan
commented Apr 28 '14, 9:34 a.m.
Hello Millard, I tried implementing this feature . I have a enumeration list with 20 values. Now when I select 12 values and save the workitem. It looks good. However when I select 13 values. I get this error.
I think it's because Medium String can hold only (1000 bytes of text). Now to solve this we need to make it as Large String (32768 bytes of text). But I'm not sure how to do that.
Please clarify the same..
Vishnu M
sam detweiler
commented Apr 28 '14, 9:42 a.m.
you cannot change an attribute type. you can create another one.
Hello Sam,
The attribute type is enumeration. What other type should I create it with ?
Regards Vishnu M
sam detweiler
commented Apr 28 '14, 10:11 a.m.
I think the attribute to RTC is a String, and you PUT an enum type presentation over it.
Hello Sam, I have created an enumeration called "System" which has 20 values(system1,system2...system20) and then created an attribute "System" of type Enumeration list with presentation Checkbox enumeration list.
Now when I choose 12 values from the checkboxes, It saves fine.
When I select 13 or more values then I get the error : value of attribute "mediumStringExtenstions.value" is 1438 bytes, which is greater than the allowed
May be define it in the script?
Here's the script definition , I have mentioned dojo.require("dojo.string") I'm guessing RTC assumes it's medium. How do I change it to large ? -----------------------
dojo.provide("com.example.test.system");
------------------------------------------------
sam detweiler
commented Apr 28 '14, 10:40 a.m.
ah, sorry.. you are using the builtin enumeration list attribute type..
showing 5 of 6
show 1 more comments
|
Millard Ellingsworth (2.5k●1●24●31)
| answered Nov 18 '13, 8:38 p.m.
FORUM ADMINISTRATOR / JAZZ DEVELOPER
Since I answer these sorts of questions often, I decided to create an article that should help with debugging issues like this: https://jazz.net/library/article/1360
|
Hi Vishnu,
I have implemented the same feature in my project area and it is working fine as excepted. I would suggest you to use a attribute type of Large String will resolve your problem. Find the script below: dojo.provide("scripts.defect.targetdatabases"); dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); dojo.require("dojo.string"); (function() { var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes; dojo.declare("scripts.defect.targetdatabases", null, { getValue: function(attribute, workItem, configuration) { var selectedValues = workItem.getValue("TargetDatabases"); var valueNames = ''; for (var i=0; i < selectedValues.length; i++) { valueNames += selectedValues[i].label + "," } if (!selectedValues){ return ""; } else{ return valueNames.substring(0,valueNames.length-2); } } }); })(); |
Hi All, I tried to return a value to “Enumeration List” of “Picker Enumartaion List”, I’m getting below error? Its working for “Enumeration” of drop down value Error running operation 'Saving Work Item' java.lang.ClassCastException: com.ibm.team.workitem.common.model.Identifier incompatible with java.util.Collection
Script :
dojo.provide("edu.millard.forumtest.ValueProvider"); (function() { dojo.declare("edu.millard.forumtest.ValueProvider", null, { getValue: function(attribute, workItem, configuration) { var selectedValues = workItem.getValue("branch3"); var valueNames ="enumBranch.literal.l4"; return valueNames; } }); })(); |
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.
Comments
as far as I know, only default value initializer scripts are run on workitem load..
everything else is run on workitem save.
I'm not aware of ANY scripts that are run realtime while typing or navigating between fields.
Other types of presentations do update live on fields that have them listed as dependencies. The Checkbox Enumeration List appears to be behaving differently.
Hi Alexander Dawson!
@abdawson1 is correct. According to this article, calculated value scripts are invoked whenever a dependent item changes.
good old dependencies.. always a rule changer!