Why attribute value is not displayed when status switch from one state to another?
sayli Boralkar (15●9)
| asked Mar 09 '17, 6:06 a.m.
edited Mar 09 '17, 6:22 a.m. by Ralph Schoon (63.6k●3●36●46)
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.
|
Accepted answer
It is not about the code, but rather how you use the code. Apparently you have two attributes, so do you use the same Calculated Value script for both? If so, it makes no sense at all, as you may end up with the same value in both attributes. If you have two scripts with one each, and the one you show is for the End Date, it does not make sense either, as the End Date value ends up depending on Start Date.
sayli Boralkar selected this answer as the correct answer
|
One other answer
|
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.