Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

JODO script to set current time for a timestamp attribute

HI All,

I want to set the current time for a attribute based on the value change of another attribute,

Can some one please help me with an example script how to do this.

Change of the estimate attribute, I want to set the due date attribute to current system date lets say as an example.

Please help me on this.

0 votes


Accepted answer

Permanent link
By "JODO", do you mean Dojo? If so, you can find plenty of examples on this forum.
https://jazz.net/forum/questions/65781/setting-default-values-for-timestamp-custom-attribute
https://jazz.net/forum/questions/113192/work-item-attribute-customization-how-to-set-current-date-in-timestamp-attribute
https://jazz.net/forum/questions/77931/attribute-configuration-calculated-timestamp-being-set-unexpectantly
seshu kumar pamidi selected this answer as the correct answer

0 votes

Comments



dojo.provide("example.calculated.TimeStampChange");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date.stamp");

(function() {
dojo.declare("example.calculated.TimeStampChange", null, {
getValue: function(attribute, workitem, configuration) {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var currentDate= new Date();
var datum = currentDate.getDate();
var mjesec = currentDate.getMonth() + 1;
var godina = currentDate.getFullYear();
var currentDateString= dojo.date.stamp.toISOString(currentDate, {milliseconds:true, zulu:true});
var systemDate = dojo.date.stamp.toISOString(new Date(godina, mjesec, datum), {milliseconds:true, zulu:true});
var result = "0";
var defectStatus = workitem.getLabel(WorkItemAttributes.STATE);

if(defectStatus == "Resolve"){
result = currentDateString
}

return result;
}



after running this script, it the defect status is of state resolve, my custom timestamp attribute need to be set wil current time, which is not happening

Also the result attribute is giving some old date, is it possible to set the date as NONEĀ  instead of some old date



after running this script, if the defect is of state resolve, my custom timestamp attribute need to set with current time, which is not happening

Also is the state is of some other instead of Resolve , the timestamp attribute is set with some old date, is it possible to set the date as NONEĀ  instead of some old date


Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 6,122

Question asked: Oct 18 '15, 5:49 a.m.

Question was seen: 2,072 times

Last updated: Oct 23 '15, 6:07 a.m.

Confirmation Cancel Confirm