It's all about the answers!

Ask a question

Attribute Customization: Can a Calculated Value use the contents of Checkbox Enumeration List without a save using JS?


Alexander Dawson (2542328) | asked Jul 15 '13, 10:22 a.m.
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?



Comments
sam detweiler commented Jul 15 '13, 11:35 a.m. | edited Oct 28 '13, 6:55 p.m.

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.


Alexander Dawson commented Jul 15 '13, 11:42 a.m.

Other types of presentations do update live on fields that have them listed as dependencies.   The  Checkbox Enumeration List appears to be behaving differently.


Tayane Fernandes commented Oct 24 '13, 8:24 a.m. | edited Oct 28 '13, 2:09 p.m.

Hi Alexander Dawson!

I'm having the same problem. Do you have found a solution for this?

Thanks


Millard Ellingsworth commented Oct 28 '13, 2:13 p.m.
FORUM ADMINISTRATOR / JAZZ DEVELOPER

@abdawson1 is correct. According to this article, calculated value scripts are invoked whenever a dependent item changes.


sam detweiler commented Oct 28 '13, 2:40 p.m.

good old dependencies.. always a rule changer!

4 answers



permanent link
Millard Ellingsworth (2.5k12431) | 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.
  1. Created an enumeration called androidVersions, added several, for example, name="KitKat" id="Android 4.4". See discussion here regarding renaming ids. if that interests you.
  2. Created a custom field for androidVersions as an enumerated checkbox presentation.
  3. Created a custom string field for androidVersionNumber and made it readonly and dependent on androidVersions attribute.
  4. Created a script that used workItem.getValue("androidversion"); to retrieve current checked values.
  5. Concatenated values of the ids from the array returned in previous step. Since there may be multiple values, you get an array of objects returned and you'll need to piece it apart to assign the value.
  6. Returned string of concatenated values.
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");
(function() {
    dojo.declare("edu.millard.forumtest.ValueProvider", null, {
        getValue: function(attribute, workItem, configuration) {
var selectedValues = workItem.getValue("androidversion");
var valueNames = '';
for (var i=0; i < selectedValues.length; i++) {
   valueNames += selectedValues[i].id + " "
}
if (!selectedValues) return "idk";
else return valueNames;
        }
    });
})();
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..


Regards

Vishnu M


sam detweiler commented Apr 28 '14, 9:42 a.m.

you cannot change an attribute type.   you can create another one.


vishnudharan manivannan commented Apr 28 '14, 10:07 a.m. | edited Apr 28 '14, 10:08 a.m.

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.

your prior post said:
>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.

12 items in 1000 chars is average 83 chars each.. pretty big for an enum choice.


vishnudharan manivannan commented Apr 28 '14, 10:27 a.m. | edited Apr 28 '14, 10:27 a.m.

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
encoded length of 1000 bytes."

  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");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.string");
(function() {

------------------------------------------------


sam detweiler commented Apr 28 '14, 10:40 a.m.

ah, sorry.. you are using the builtin enumeration list attribute type..

I don't think there is a way to change its storage size.

showing 5 of 6 show 1 more comments

permanent link
Millard Ellingsworth (2.5k12431) | 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

permanent link
Balamurugan Selvarasu (331430) | answered Jan 21 '16, 4:10 a.m.
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);
       
        }
           
        }
    });
})();

permanent link
Sachin Nairy (5111320) | answered Aug 07 '17, 6:57 a.m.

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


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.