Set a tag using Calculated Values script
I'm trying to set a default/dynamic tag based on work-item type using Calculated Values script
I tried this code:
// IWorkItem workItem = workingCopy.getWorkItem(); List<string style="box-sizing: border-box;"> tags = workItem.getTags2(); tags.add("NewTag"); workItem.setTags2(tags);</string><string style="box-sizing: border-box; font-size: 13px;">
<string style="box-sizing: border-box; font-size: 13px;">
This is the error:
</string>
<string style="box-sizing: border-box; font-size: 13px;">
com.ibm.team.repository.common.TeamRepositoryException: Unexpected exception type at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.handleException(ScriptAttributeValueProvider.java:281) at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.getValue(ScriptAttributeValueProvider.java:69) at com.ibm.team.workitem.common.internal.attributeValueProviders.AttributeValueProviderRegistry$SafeValueProvider.getValue(AttributeValueProviderRegistry.java:44) at com.ibm.team.workitem.common.internal.model.impl.AttributeImpl.getValue(AttributeImpl.java:899) at sun.reflect.GeneratedMethodAccessor147.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56) at java.lang.reflect.Method.invoke(Method.java:620) at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:597) at com.sun.proxy.$Proxy47.getValue(Unknown Source) at com.ibm.team.workitem.client.internal.DependencyHandler$Worker.runProtected(DependencyHandler.java:51) at com.ibm.team.foundation.client.util.FoundationJob.run(FoundationJob.java:68) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot find function setTags2 in object [object com.ibm.team.workitem.common.internal.scripting.WorkItemAPIType]. (settagsaos.js#17)
</string>
</string>
<string style="box-sizing: border-box; font-size: 13px;">
</string>
<string style="box-sizing: border-box; font-size: 13px;">
What did I do wrong? how can I create a tag using dojo script base code?
</string>
<string style="box-sizing: border-box; font-size: 13px;">
</string> <string style="box-sizing: border-box; font-size: 13px;">Gil</string> |
Accepted answer
Ralph Schoon (63.1k●3●36●45)
| answered Jul 25 '18, 11:31 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER For all I can tell you can not set a tag using JavaScript attribute customization.
Gil Br selected this answer as the correct answer
|
One other answer
Ralph Schoon (63.1k●3●36●45)
| answered Jul 24 '18, 11:15 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER The code you refer to is code for the Plain Java Client Libraries and not for the JavaScript API. This is the information for attribute customization: https://jazz.net/wiki/bin/view/Main/AttributeCustomization you basically have setValue() and that is it.
Comments
Gil Br
commented Jul 24 '18, 11:52 a.m.
Hi Ralph,
Thanks for the prompt answer!
Tags is of type List
This still fails:
getValue: function(attribute, workItem, configuration) {
// return ["SAOS"]; //fails with: Error running operation 'Creating Work Item'
java.lang.String incompatible with java.util.Collection
//Trying:
workItem.setValue(attribute, ["SAOS"]);
This is the error:
TypeError: Cannot find function setValue in object [object
com.ibm.team.workitem.common.internal.scripting.WorkItemAPIType].
Trying to add:
setValue: function(attribute, workItem, configuration) {
//Also fails to run
Please advise
Gil
Ralph Schoon
commented Jul 24 '18, 12:19 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Sorry, I can't. Not sure how that should work. For API examples read https://jazz.net/wiki/bin/view/Main/AttributeCustomization
Last lab.
https://www.google.com/search?q=java+script+set+tag+site%3Ajazz.net suggests that this might not be supported.
Gil Br
commented Jul 25 '18, 8:47 a.m.
I have the SDK API working version, there it uses:
List<String> tags = workItem.getTags2();
tags.add("MyNewTag");
WorkItemWorkingCopy wcsrc = wcm.getWorkingCopy((IWorkItemHandle) workItem.getItemHandle());
wcsrc.getWorkItem().setTags2(tags);
I need the Dojo script Calculated Values script based version for returning or converting a string to a collection (the type of Tags).
Is there any other way to set a default tag per work-item type?
I like to identify a work-item that has been moved from one Project Area to another.
Any thoughts ideas are welcome
Gil
I doubt you can even detect a work item is moved (versus just created) in the JavaScript Attribute customization.
Gil Br
commented Jul 25 '18, 10:49 a.m.
My thought was to set a tag to the work-item before the move and detect it by the tag after the move. The work-item is created in the original Project Area as a child work-item and with a unique type so I wanted every such work item type to have a mark, tag in this case. Is there a way to set a default tag to a specific work-item type (e.g. task) either from script or from Default Values?
Gil
showing 5 of 6
show 1 more comments
|