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

Compare TIME_SPENT value

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                                                

0 votes


Be the first one to answer this question!

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
× 10,938

Question asked: Oct 25 '15, 8:46 a.m.

Question was seen: 2,141 times

Last updated: Oct 25 '15, 8:46 a.m.

Confirmation Cancel Confirm