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

work item attribute customization: disable time spent on past DUE DATE

 Hi,

I need some help here.

I created the following condition script for setting read-only TIME SPENT attribute when DUE DATE is past:

dojo.provide("com.apisit.disable.timeEnter");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
    dojo.declare("com.apisit.disable.timeEnter", null, {

        matches: function(workItem, configuration) {
   
   
   
    var currentDate= new Date();
    var day = currentDate.getDate();
    var month = currentDate.getMonth() + 1;
    var year = currentDate.getFullYear();
    getAttributeData("Due Date: ", WorkItemAttributes.DUE_DATE);
    var date_enter = dojo.date.stamp.fromISOString(workItem.getValue(WorkItemAttributes.DUE_DATE));
   
    var day_enter = date_enter.getDate();    

    if(day > day_enter){
    return true;
    }
    else
    {
    return false;
    }
        }
    });
})();

Then, in Operation Behavior I choose Read-Only Attributes For Condition for adding this script, where I choose Time Spent attribute,
but it doesn't work.
Where I mistake..?

Regards,


0 votes



6 answers

Permanent link
Milan,
have you tried to add
console.log(.....); to see the actual values and kind of debug your script?

/Elisabeth

0 votes

Comments

 HI Elisabeth,


Yes, I made also another script for console logs to show outputs on Description work item attribute, and when I choose past date in DUE DATE, I can see the changes in Description. For example, if I choose 18. May of 2013, as past date I get 18, and for current date I get 25.
I also put one if to match the values which is bigger, just to ensure that I got real values for dates, and It works.

But I am wondering why this doesn't work for time spent...


Permanent link
 Hello,
you may want to compare your code with the one available here - https://jazz.net/library/article/1003/#calc-values

Hope it helps.
Eric.

0 votes


Permanent link
 Hi Eric,

I tried this:

dojo.provide("com.apisit.disable.timeEntering");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
    dojo.declare("com.apisit.disable.timeEntering", null, {

        matches: function(workItem, configuration) {
    
    
    
     var currentDate= new Date();

     var due_date = dojo.date.stamp.fromISOString(workItem.getValue(WorkItemAttributes.DUE_DATE));  


     if(dojo.date.compare(due_date,currentDate) < 0){ //if due_date is earlier than today date
     return true;
     }
     else
     {
     return false;
     }
        }
    });
})(); 

but this doesn't work also... :(

0 votes


Permanent link
 Hello Milan,
date compare is performed using: dojo.date.compare
so your code should be OK

As Elisabeth underlined, you may want to console.log(due_date);
and ensure it's not null or check the format.

Hope it helps
Eric.

0 votes

Comments

Hi Eric, 


it works now :)

I forgot to write the following line:

var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;

I found it in log file that I am missing it.

Thanks for the help, to you and  Elisabeth.

Regards,

 glad it works now.

Thanks


Permanent link

 Hi,


I tried the above code which works for you but its not working for me.


0 votes

Comments

Consider creating a question including your code and what you are trying to do. 


Permanent link

 HI, 


I tried the below code

dojo.provide("com.apisit.disable.timeEntering");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {

var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;

    dojo.declare("com.apisit.disable.timeEntering", null, {

        matches: function(workItem, configuration) {
    
    
    
     var currentDate= new Date();

     var due_date = dojo.date.stamp.fromISOString(workItem.getValue(WorkItemAttributes.DUE_DATE));  


     if(dojo.date.compare(due_date,currentDate) < 0){ //if due_date is earlier than today date
     return true;
     }
     else
     {
     return false;
     }
        }
    });
})();  


Please review and suggest.

0 votes

Comments

Hi,


Please suggest how to configure the cod to project/work item. 

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
× 7,495
× 57
× 35

Question asked: May 28 '13, 4:22 a.m.

Question was seen: 6,114 times

Last updated: Oct 23 '19, 12:39 a.m.

Confirmation Cancel Confirm