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

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

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

0 votes

Comments

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


Accepted answer

Permanent link
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

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
× 10,938

Question asked: Jun 16 '15, 11:01 a.m.

Question was seen: 3,466 times

Last updated: Apr 13 '16, 5:13 a.m.

Confirmation Cancel Confirm