Restrict to select past date
4 answers
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:
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
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) {
if (dojo.date.compare(endDate, beginDate) >= 0) {
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:
- Validatior attribute customization, JavaScript or Java
- 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");
}
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");
}