It's all about the answers!

Ask a question

Blanking StringList attributes


Andrea Perniciano (33) | asked Oct 09 '14, 2:51 a.m.
Hi all,
is there anybody out there than can help me on how to blank out a string list attribute based on the change of the "filed against" attribute ?

I had to use the string list (associated to a HTTP Filtered Value Set) because  there is not the possibility to manage a dependent enumeration value set for enumeration list attributes. My set of values depends upon the Work item category, and when I change this attribute I need to clean up my string list attribute because it usually contains incoherent values if populated with a different work item category.

My solution should be to clean out the string list on the change of the category, and I would like to do it at client level, with any type of attribute customization, but I dont know how to do it. I tried with multi line text and javascript providers with no results: would you please help me ?

Thanks,
kind regards
andrea

Accepted answer


permanent link
Ralph Schoon (63.1k33645) | answered Oct 09 '14, 4:47 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Andrea,

I tried JavaScript and it does not work. This script should do it:
/*******************************************************************************
 * 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.CleanListValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
	var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
    dojo.declare("com.example.CleanListValueProvider", null, {

        getValue: function(attribute, workItem, configuration) {
            //var category = workItem.getValue(WorkItemAttributes.FILED_AGAINST);
            var category = workItem.getLabel(WorkItemAttributes.FILED_AGAINST);
            console.log("Category: " + category);
            if (category=="Core"){
            	 //var result= [];	
            	 var result= null;	
			     return result;
			}
			// var result= null; // Works but not desired
			return workItem.getValue(attribute); // java.lang.String incompatible with java.util.Collection
        }
    });
})();

Unfortunately it does not.  I can basically not even return the original value of the attribute (to not change the value in case it is not supposed to be). I think List attributes are currently at least not supported in JavaScript based calculated values. They work only for value sets. Feel free to file a defect or enhancement request.

I can only return null to clear the values, but since I always have to return a value, that means it will always clear the attribute if the category changes. Not very helpful.

you could try to follow https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ and create a calculated value in Java. In this case you can return a List or Collection of string values, which should work.

Andrea Perniciano selected this answer as the correct answer

Comments
Andrea Perniciano commented Oct 09 '14, 7:37 a.m.

Hi Ralph,
I actually tried something like that, and I agree there are some more work to do with the xList attribute types to enhance their usability.

I'll try to work on a java attribute validation

Thank you

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.