Script based Default Value
Hi
This is my code :
dojo.provide("Default_Value.task");dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");dojo.require("dojo.date");dojo.require("dojo.date.stamp");
(function() {var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("Default_Value.task", null, {
getValue: function(attributeId, workItem, configuration) {var wi_type = workItem.getValue(WorkItemAttributes.TYPE);var wi_owner = workItem.getValue(WorkItemAttributes.OWNER);console.log("Type - " + wi_type);console.log("Owner - " + wi_owner);if (wi_type == "task"){wi_owner = "_p_g14CR6EeWmoeAO1lg85w";}return wi_owner;}});})();
Accepted answer
The function should be getDefaultValue, not getValue. You can use the "Fill in example" link to get the skeleton of the script to avoid such simple mistake.
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_based_default_values
Comments
Hi Donald
More details please?
One scenario where it definitely will not work is creation. The default value provider will be executed on the server side before the editor is rendered on the web UI. At that time, all attributes have no value, so your script will always return null. You can add console.log() to debug and confirm this.
The code above is bogus I suggest to read the instructions again https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_based_default_values
I changed my script and worked I needed to add this :