Setting default values for Timestamp Custom Attribute
Hi everyone.
I've spent some hours with this issue and I haven't been able to find a solution, so I hope to find help in this forum :)
I've declared a custom attribute with a script-based default value, returning the current date. So far so good.
Then, in my work item presentation I've inserted two fields: one of them is text-based, and the other one, a Timestamp. Both of them get their default values from the same attribute and the same script, but when I create a new Work Item, the text-based field displays the default value properly (a string with the current date), but the Timestamp shows the string 'None', and it's still needed to pick a Date to fill the field.
Does anyone know how to set a default value to a Timestamp presentation?
Thanks in advance.
Dani G.
I've spent some hours with this issue and I haven't been able to find a solution, so I hope to find help in this forum :)
I've declared a custom attribute with a script-based default value, returning the current date. So far so good.
Then, in my work item presentation I've inserted two fields: one of them is text-based, and the other one, a Timestamp. Both of them get their default values from the same attribute and the same script, but when I create a new Work Item, the text-based field displays the default value properly (a string with the current date), but the Timestamp shows the string 'None', and it's still needed to pick a Date to fill the field.
Does anyone know how to set a default value to a Timestamp presentation?
Thanks in advance.
Dani G.
10 answers
Hi Daniel,
I followed https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Default_values to do the same. My code looked like:
Unfortunately I have the same effect as you describe in the default value provider. The Eclipse client log shows the error below and I assume this is a bug in the experimental Javascript engine:
I followed https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Default_values to do the same. My code looked like:
dojo.provide("com.example.CurrentDateDefaultValueProvider");
dojo.require("dojo.date"); // We need the date class from Dojo to compare two dates
dojo.require("dojo.date.stamp"); // We need the stamp class to work with ISO date strings
(function() {
dojo.declare("com.example.CurrentDateDefaultValueProvider", null, {
getDefaultValue: function(attribute, workItem, configuration) {
var now=new Date();
var date= dojo.date.stamp.toISOString(now, {milliseconds:true, zulu:true});
console.log("Now is: " + date);
return date;
}
});
})();
Unfortunately I have the same effect as you describe in the default value provider. The Eclipse client log shows the error below and I assume this is a bug in the experimental Javascript engine:
!ENTRY com.ibm.team.rtc.common.scriptengine 1 0 2011-10-25 14:03:15.544
!MESSAGE LOG: Now is: 2011-10-25T12:03:15.532Z
!ENTRY com.ibm.team.workitem.common 4 0 2011-10-25 14:03:15.546
!MESSAGE Error invoking default value provider 'com.ibm.team.workitem.valueproviders.DEFAULT_VALUE_PROVIDER._YUUP8P76EeCRy-8MDpVeRg'
!STACK 0
java.lang.NumberFormatException: For input string: "2011-10-25T12:03:15.532Z"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:63)
at java.lang.Long.parseLong(Long.java:427)
at java.lang.Long.parseLong(Long.java:476)
at com.ibm.team.workitem.common.internal.model.TimestampAttributeType.valueOf(TimestampAttributeType.java:34)
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.convert(ScriptAttributeValueProvider.java:111)
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.getDefaultValue(ScriptAttributeValueProvider.java:65)
at com.ibm.team.workitem.common.internal.attributeValueProviders.AttributeValueProviderRegistry$SafeDefaultValueProvider.getDefaultValue(AttributeValueProviderRegistry.java:83)
at com.ibm.team.workitem.common.internal.model.impl.AttributeImpl.getDefaultValue(AttributeImpl.java:889)
at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:597)
at $Proxy24.getDefaultValue(Unknown Source)
at com.ibm.team.workitem.common.internal.WorkItemCommon.createWorkItem(WorkItemCommon.java:207)
at com.ibm.team.workitem.client.internal.WorkItemWorkingCopyRegistry.createNewUnconnected(WorkItemWorkingCopyRegistry.java:586)
at com.ibm.team.workitem.client.internal.WorkItemWorkingCopyRegistry.connectNew(WorkItemWorkingCopyRegistry.java:580)
at com.ibm.team.workitem.client.internal.WorkItemWorkingCopyManager.connectNew(WorkItemWorkingCopyManager.java:94)
at com.ibm.team.workitem.client.WorkItemOperation.run(WorkItemOperation.java:230)
at com.ibm.team.workitem.client.WorkItemOperation.run(WorkItemOperation.java:189)
at com.ibm.team.workitem.rcp.ui.internal.actions.NewWorkItemAction$2.runProtected(NewWorkItemAction.java:338)
at com.ibm.team.foundation.client.util.FoundationJob.run(FoundationJob.java:68)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Hi Daniel,
just to let you know, there was a work item for it and it is fixed - I checked default value provider - in 3.0.1.1.
just to let you know, there was a work item for it and it is fixed - I checked default value provider - in 3.0.1.1.