Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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?


0 votes

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!

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

Thanks

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

good old dependencies.. always a rule changer!



4 answers

Permanent link
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).

0 votes

Comments

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

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

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.

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() {

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

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
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

0 votes


Permanent link
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);
       
        }
           
        }
    });
})();

0 votes


Permanent link

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;

        }

    });

})();

0 votes

Your answer

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

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,935
× 152

Question asked: Jul 15 '13, 10:22 a.m.

Question was seen: 10,120 times

Last updated: Aug 07 '17, 6:57 a.m.

Confirmation Cancel Confirm