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

Restrict to select past date

 Hi,


We are using 6.o.5 version of RTC in that work item we are using the date attribute that its taking past date also.We want restrict the past date and able to select present date and future date for that particular attribute.

Please suggest us.

0 votes



4 answers

Permanent link
You can use script based validation for this. Look at the date validation example, which gives you a very close example of what you need. If you have not used the work item attribute customization features before, you need to enable the repository first.

Check the first section for those steps:

Then configure using this as a basis:

0 votes


Permanent link

 Hi ,


I tried the below code,but it's not worked for me..Please suggest any configuration we have to do or to change any of the code lines.

dojo.provide("ibm.example.workitems.providers.CalculatedValueSkeletons"); 
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); 
dojo.require("dojo.date"); 
dojo.require("dojo.date.stamp"); 

(function() { 
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes; 

dojo.declare("ibm.example.workitems.providers.CalculatedValueSkeletons", null, { 

    getValue: function(attributeId, workItem, configuration) { 


    var dueDate= dojo.date.stamp.fromISOString(workItem.getValue(WorkItemAttributes.auditplandate)); 
        var currentDate= new Date(); 
        var dayDiff= dojo.date.difference(dueDate,currentDate, "day"); 
        var result = 0; 
    if (dayDiff > 0) result=dayDiff;          
    } 
        return result; 
    } 
}); 
})(); 

Regards,
ALMSUPPORT

0 votes


Permanent link
This has worked for me, I think:

        // Compare the two dates and make sure endDate is not earlier than beginDate
        if (dojo.date.compare(endDate, beginDate) >= 0) {

0 votes

Comments

Hi,


 Without comparison we can't disable future date?.
We have attribute called Due date in that we have to disable past dates.

If it is possible please suggest the code.

Regards,
ALMSUPPORT


Permanent link
As Ian has rightly pointed out this can be done with a validator e.g. using JavaScript. These are the general options I am aware of:

  1. Validatior attribute customization, JavaScript or Java
  2. Custom work item save advisor
In any case you have to do a comparison. Note, you need a validator and not a calculated value. If you do not understand the difference, you are unable to use the code.See https://jazz.net/wiki/bin/view/Main/AttributeCustomization

This is as much code as I have for such an example:

        // Get the current attribute's value and make a Date object from it
        var endDate= dojo.date.stamp.fromISOString(workItem.getValue(attributeId));
       
        // Compare the two dates and make sure endDate is not earlier than beginDate
        if (dojo.date.compare(endDate, beginDate) >= 0) {
            return Status.OK_STATUS;
        } else {
            return new Status(Severity[ERROR], "The completion date can not be earlier than the start date");
        }

0 votes

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

Question asked: Oct 22 '19, 8:05 a.m.

Question was seen: 1,805 times

Last updated: Dec 06 '19, 3:21 a.m.

Confirmation Cancel Confirm