It's all about the answers!

Ask a question

Restrict to select past date


almsupport alm (1319) | asked Oct 22 '19, 8:05 a.m.
edited Oct 22 '19, 8:05 a.m.

 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.

4 answers



permanent link
Ian Wark (79713553) | answered Oct 24 '19, 9:21 p.m.
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:

permanent link
almsupport alm (1319) | answered Dec 05 '19, 5:13 a.m.

 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


permanent link
Ralph Schoon (63.5k33646) | answered Dec 05 '19, 5:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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) {

Comments
almsupport alm commented Dec 05 '19, 5:31 a.m.

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
Ralph Schoon (63.5k33646) | answered Dec 06 '19, 3:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Dec 06 '19, 3:21 a.m.
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");
        }

Your answer


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.