Return a list of categories from a script based value set provider?
I'm trying to filter the list of categories, displayed by the "Filed Against" editor presentation, by using a script based value set provider. However, for some reason I can not return more than one category. Returning an array with one item works, returning multipe entries does not.
This works:
dojo.provide("com.example.ValueSetProvider");
This does not:
dojo.provide("com.example.ValueSetProvider"); (function() { dojo.declare("com.example.ValueSetProvider", null, { getValueSet: function(attributeId, workItem, configuration) { var result= []; result.push("_WStlQChtEeS6O_h3MSj9RQ"); result.push("_ABClQChtEeS6O_h3MSj9DE"); return result; } }); })();
Is it possible at all to return more than one category when using a script based value set provider?
|
3 answers
Here is the stacktrace I get whenever I have more than one identifier in my results array:
*** Error: Error loading properties for editing the work item | Details: com.ibm.team.workitem.common.internal.model.impl.CategoryHandleImpl incompatible with com.ibm.team.workitem.common.model.ICategory Comments Hello Alexander,
I tested on my side and it works OK.
Given the above, I don't think the script itself is a problem,
rather the attribute type where it's used.
I used my sample for feed a String List attribute - works fine.
As the script returns an Array of String - your attribute must be of that type , or compatible,
or you'll get an error (like the one you have)
Eric
Alexander Maret-Huskinson
commented Aug 25 '14, 6:56 a.m.
Hello Eric,
yes, it works with string lists but I really need to filter the "Filed Against" attribute.
To me this looks like a bug. The system properly detects that those identifiers are category handles and converts them into a CategoryHandleImpl instance. Unfortunately the sort method expects elements which implement the ICategory interface and therefore fails. It works with only one element as a list with only one element does not get sorted.
Should I open a bug report or is this really the expected behaviour? If it is the expected behaviour there would be no way to filter the "Filed Against" attribute with a value set provider. Or is there?
I think the fix shouldn't be too complicated. The category handles simply have to be converted to elements which do implement the ICategory interface before passing them to the sort method.
Alex
|
Can you try with OOTB template?
/*******************************************************************************
* 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.ValueSetProvider"); (function() { dojo.declare("com.example.ValueSetProvider", null, { getValueSet: function(attributeId, workItem, configuration) { var result= []; result.push("a"); result.push("b"); return result; } }); })(); Comments
Alexander Maret-Huskinson
commented Aug 22 '14, 3:49 a.m.
I did. The examples above are the OOTB templates except for the values I push into the results-array. These are exactly the scripts I have tried, they are a 1:1 copy & paste from the Eclipse IDE. yes - I recognized the template.
Did you try to output (console.log()) the content of the array ?
You may want to use Firebug to check for any error in the console.
Sorry for the late answer, the system didn't notify me about your reply.
I do indeed get an error message and a stack trace whenever I have more than one category identifier in my results array. I'll post the stacktrace as a new reply as it is too long for a comment.
|
Hello Alexander,
this should work as the VSP is designed to return an Array - so expect the Array to be able to have more than 1 element.
Comments
Alexander Maret-Huskinson
commented Aug 22 '14, 3:39 a.m.
Well, unfortunately it does not. My second example throws an error 500 even though the IDs are correct.
Each ID on its own shows up correctly in the "Filed Against" dropdown. Returning both IDs however throws an error 500.
|
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.