It's all about the answers!

Ask a question

Compare TIME_SPENT value


Chen Ben ezra (41427) | asked Oct 25 '15, 8:46 a.m.
Hi , 

Im trying to create a script based condition that will check if task   
is in status complete for defect type and TIME_SPENT is not zero.   
I can find the way to compare the value of TIME_SPENT.                  
                                                                        
This is my java script:                                                 
dojo.provide("org.example.workitems.providers.                          
CheckTimeRemainingForTask");                                            
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");    
                                                                        
(function() {                                                           
var WorkItemAttributes= com.ibm.team.workitem.api.common.               
WorkItemAttributes;                                                     
var scriptname = "CheckTimeRemainingForTask";                           
var doDebug = true;                                                     
                                                                        
dojo.declare("org.example.workitems.providers.                          
CheckTimeRemainingForTask", null, {                                     
    matches: function(workItem, configuration) {                        
var type = workItem.getValue(WorkItemAttributes.TYPE);                
var state = workItem.getValue(WorkItemAttributes.STATE);//3 =        
complete                                                                
var timespent = workItem.getValue(WorkItemAttributes.TIME_SPENT);     
                                                                        
if ((type === "task") &&                                              
    (state === "3") &&                                                
(timespent > 0 )){                                                   
debug("type is task and state is complete and timespent is not zero  
!!!!!");                                                                
}                                                                     
                                                                        
return ((type === "task") &&                                          
    (state === "3") &&                                                
(timespent > 0 ));                                                   
                                                                        
                                                                        
function debug(display){                                              
if(doDebug){                                                         
console.log(scriptname+ "-" + display);                             
}                                                                    
}                                                                      
}                                                                      
});                                                                     
})();                                                                   
                                                                        
The timespent type is number (I checked with the command typeof).       
The value of timespent when I print it to the console is: 39600000.     
I tried to compare with the operators > 0 , == 0 , convert to       
string and compare to 39600000 but nothing works.                     
                                                                        
Can someone help me with this issue ?                                   
                                                                        
BR,                                                                     
Chen                                                

Be the first one to answer this question!


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.