It's all about the answers!

Ask a question

Due date validation is not working between current date(System generated date) post noon(Saudi Time)


Rajiv Gandhi (34812) | asked Jun 16 '15, 11:01 a.m.

Dear Team,

 

We have implemented java scrip in RTC workitem for date validation. It satisfies the condition that due date should be greater than or equal to current date(System generated Date). We are observing the following limitations

 

 

1)      (Due Date >= Current Date), this condition works fine till Mid noon(Saudi Time) but it doesn’t work post noon during creation of RTC workitem.

 

We are not clear on what exactly is the reason behind this issue. Can anyone help me out on this regard?.

 

FYI: The below one is the created script for workitem date validation.


dojo.provide("DueDateValidation");

dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); // To access the work item attributes
dojo.require("com.ibm.team.workitem.api.common.Status"); // To create a status object to return
dojo.require("com.ibm.team.workitem.api.common.Severity"); // To create a severity for the status
dojo.require("dojo.date"); // We need the date class from Dojo to compare two dates
dojo.require("dojo.date.stamp"); // We need the stamp class to work with ISO date strings


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

var DateValidator = dojo.declare("DueDateValidation", null, {

    validate: function(attributeId, workItem, configuration) {
        var severity = "ERROR";
        var message = "Due Date cannot be less then Current Date";
    var GetCurrentDate = new Date();
        var CurrentDate = GetCurrentDate.getTime().toString();
    var GetDueDate = dojo.date.stamp.fromISOString(workItem.getValue(com.ibm.team.workitem.api.common.WorkItemAttributes.DUE_DATE));
    var duedate = GetDueDate.getTime().toString();
    var PHED = dojo.date.stamp.fromISOString(workItem.getValue("HandoverPlannedEndDate"));
    var StringPHED = PHED.getTime().toString();

            
        // Compare the two dates and make sure DueDate is not earlier than CurrentDate
        if ((workItem.getValue(WorkItemAttributes.TYPE)=="change_request") && (duedate >= CurrentDate)) {
            return Status.OK_STATUS;
        }else {
            return new Status(Severity[severity], message);
        }
    }
});
})();



Thanks,

Rajiv


Comments
Arjun Pande commented Apr 12 '16, 11:09 p.m. | edited Apr 13 '16, 5:13 a.m.

How do u configure this to make it work in templates?

Accepted answer


permanent link
Rajiv Gandhi (34812) | answered Feb 18 '16, 2:35 a.m.
After using the below time functionality, my script is working fine as expected 

//Get current date without time information like YYYY/MM/dd
    var CurrentDate=dojo.date.locale.format(new Date(),{datePattern: "yyyy/MM/dd", selector: "date"});
Ralph Schoon selected this answer as the correct answer

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.