Hello guys,
I want to set current date and time after selecting workflow from New---->In Progress and In Progress----->Completed.
For this I made two different attributes of type small string and give dependency of Status attribute and add JavaScript created in Calculated Values. whenever I select "Start Working" status from status field then current date and time is displayed on start date attribute but when I select Complete status from status field then actual end date is set to attribute of end date but Start date is not displayed.
for more clearance I Paste my JavaScript code below :
dojo.provide("actualenddatescript"); // class name
dojo.require("dojo.date.stamp");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("actualenddatescript", null, {
getValue: function(attribute, workItem, configuration) {
var abc;
var currentDate= new Date();
var datum = currentDate.getDate();
var mjesec = currentDate.getMonth() + 1;
var godina = currentDate.getFullYear();
var hours = currentDate.getHours();
var minutes = currentDate.getMinutes();
var seconds = currentDate.getSeconds();
var result = datum+"-"+mjesec+"-"+godina+" "+hours+":"+minutes+":"+seconds+".";
var state = workItem.getValue(WorkItemAttributes.STATE);
var state1=workItem.getValue("work_started");
var state2 = workItem.getValue("actual_ed");
if (state.toString() == "com.ibm.team.workitem.taskWorkflow.state.s2") //Id of In Progress state
{
if(state1)
{
return state1.toString();
}
else
{
abc = result ;
return abc.toString();
}
}
if (state.toString() == "com.ibm.team.workitem.taskWorkflow.state.s1") //Id of New State
{
}
if (state.toString() == "com.ibm.team.workitem.taskWorkflow.state.s3") //Id of Complete State
{
if(state2)
{
return state2.toString();
}
else
{
abc = result;
return abc.toString();
}
}
else
{
}
return "";
}
});
}) ();
please correct me if I am wrong in above code.