It's all about the answers!

Ask a question

error on tags attribute customization


Leonardo Schuler (1113) | asked May 02 '18, 4:34 p.m.

I am trying to create an attribute customization on the tagsĀ  field, in order to add additional tags.
the tag field seem to accept only a collection type, but when I read the value it returns a common string (values separated by comma)

the following code simply reads the value of the Tags attribute and try to set the same value, the other example I tried are commented - I tried to return an array and a javascript object/ collection. none of the options worked, I always get the following error:

Error: java.lang.String incompatible with java.util.Collection | Details: java.lang.String incompatible with java.util.Collection

(this error appears even when I return an object or array)
I would like to know what is the valid format that this attribute expects to receive, there is no place in the documentation talking about this format.

I removed the source code because the question was being flagged as spam!!!


Comments
Leonardo Schuler commented May 02 '18, 4:35 p.m.
dojo.provide("util.RTCPlayArea.TestValue");
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("util.RTCPlayArea.TestValue", null, {

        getValue: function(attribute, workItem, configuration) {
            console.log(attribute);
            // return [test", "test2"] 
            // return {"0":"test","1":"test2"}
            return workItem.getValue(attribute); //get Value returns a string

        }
    });
})();

Ian Wark commented May 03 '18, 4:32 a.m.

I know this isn't guaranteed to work.
https://jazz.net/forum/questions/102338/how-to-do-attribute-customization-to-clear-description-field

I'll test this out and see if I can figure out. Have you tried return {{val1|val2}}; type syntax? This can be used to return values in HTML type fields.

I don't think this is critical, but I recommend obtaining the value of the Tags attribute using the built-in WorkItemAttributes.TAGS.

2 answers



permanent link
Ian Wark (79713553) | answered May 06 '18, 7:50 p.m.

I was easily able to reproduce the behavior you describe. The {{ }} syntax didn't seem to work. I am afraid I can't find a solution to this using Javascript. I think you could do this without too much problem using a Java based attribute customization, where it is easy to control what type is returned. Let me know if you are interested to know more about how to do that. You can find some useful tips in the bottom of the wiki page and in pages created by Ralph Schoon:

https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Providing_new_customizations_imp

https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/


permanent link
Leonardo Schuler (1113) | answered May 07 '18, 9:49 a.m.

I will post here Ian's Wark comment so it can be considered the final answer:

"I was easily able to reproduce the behavior you describe. The {{ }} syntax didn't seem to work. I am afraid I can't find a solution to this using Javascript. I think you could do this without too much problem using a Java based attribute customization, where it is easy to control what type is returned. Let me know if you are interested to know more about how to do that. You can find some useful tips in the bottom of the wiki page and in pages created by Ralph Schoon:

https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Providing_new_customizations_imp

https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/
"



Javascript customization have its limitations, which include handling complex type attributes - so it is not possible to assign new tags using javascript customization

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.