It's all about the answers!

Ask a question

Attribute type "Timestamp" update default time for attributes with type timestamp


nannette Mori (501985) | asked Jan 11 '18, 10:42 a.m.

When I manually update a date field, the default time is 12 00 00 00 pm.  Is there a way to change the default time gobally for all date/timestamp fields?

Example If I Update the approval date manually using the calendar popup the default time is 12 00 00 00 pm - can that be changed without having to update the time manually when updating the date.


Comments
Donald Nong commented Jan 12 '18, 2:37 a.m.

I don't quite understand what you want to achieve? Do you want a "day only" attribute?


Ian Wark commented Jan 12 '18, 2:38 a.m.

I don't think so. I believe the date picker hard codes the default time as 12 noon. You can choose whether to make a timestamp a date or a date + time field initially in the editor presentation, but I think that is all. And the approval one is already there, so you can't customize it.

I get that impression from here:
https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=239758


Ian Wark commented Jan 12 '18, 2:52 a.m.

You might be able to define a default timestamp via Script-based default values. I haven't tested this with a timestamp type though. In this case you won't have to use the picker to choose a date. You can't specify a default timestamp value without writing your own Javascript, though. It isn't one of the options provided.

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

One answer



permanent link
Ian Wark (79713553) | answered Jan 16 '18, 8:32 a.m.
edited Jan 16 '18, 8:36 a.m.

I'm going to have a go at answering your question. Please tell us if your question was different.

You can change the hour, minutes of all the Timestamp type attributes in a work item (bar those in Approvals tab -- that object can't be broken down) by defining an attribute customization for a Calculated Value of provider type Script-based Calculated Value. You do that by following the below link and writing a little snippet of Javascript.

Calculated Values
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_based_calculated_values

For example, you could write something like the below to remove the time portion whenever saving a work item:



dojo.provide("com.example.common.RemoveTimeCalc");

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("com.example.common.RemoveTimeCalc", null, {

    getValue: function(attributeId, workItem, configuration) {

        var currentDate= dojo.date.stamp.fromISOString(workItem.getValue(WorkItemAttributes.DUE_DATE));
        //console.log("The value of currentDate is: " + currentDate);

        if (currentDate != null) {
            currentDate.setHours(0);
            currentDate.setMinutes(0);
            currentDate.setMilliseconds(0);

            var isoDate= dojo.date.stamp.toISOString(currentDate, {milliseconds:true, zulu:true});
            return isoDate;
        } else { return null; }
    }
});
})();



You need to alter the WorkItemAttributes.DUE_DATE bit so that it matches the field you are applying it to. But the rest of the script, except for the name can be reused for each Timestamp field.

<Steps>
1. Go to the project area configuration in Eclipse under Workitems > Attribute Customization and add an entry under Calculated Value.
2. Paste the script as is here into the script section on the right.
3. Go to Workitems > Types and Attributes > select the correct work item type > scroll down to your attribute > Edit > add your new calculated value to the Due Date field
4. Repeat steps 1-3 changing the name of the script each time and altering the attribute name. For built-in attributes you can use WorkItemAttributes.XXXXXXX type name, as per https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Accessing_built_in_attributes_of .

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.