It's all about the answers!

Ask a question

Date comparision condition is not working while checking it second time

Sajjad Ali Khan (314152) | asked Oct 06 '15, 9:51 a.m.
I have created a java script for date comparison which returns error if both dates are not same, while after creating condition i did a test on the condition but on first attempt condition behave as i expect but on the second attempt condition just returns the alert  but not the ERROR.

I'm not able to figure out what's wrong with my code, if anyone could help me out to resolve this issue that would be great.

Following is my code:



(function () {

    var Severity =;
    var Status =;

    dojo.declare("com.example.estimateddeploymentdatevalidation", null, {

        validate: function (attribute, workItem, configuration) {
           // require(["dojo/dom", "dojo/dom-style"], function (dom, domStyle) {

                var estimatedDate ="arabbank.attribute.EstimatedDeploymentDate"));
                var deploymentDate ="arabbank.attribute.DateTime"));

                if (estimatedDate != null && deploymentDate != null) {
                    var diff =, deploymentDate, "day");
                    if (diff != 0) {
                        var severity = "ERROR";
                        var message = "Estimated DeploymentDate & Deployment Date must be same";
                        return new Status(Severity[severity], message);
                return Status.OK_STATUS;

One answer

permanent link
Donald Nong (14.5k414) | answered Oct 06 '15, 10:35 p.m.
The issue is not caused by your code, as I can easily reproduce the problem by using a simple "return" statement. I will rephrase the problem here:
If a script-based validator is present, it will be executed _once_ when the work item is loaded, and the red indicated is shown if an error message is returned. When the attribute value is changed, the validator is executed _twice_, and the red indicator is not shown regardless the valid state. This refers to the RTC Web client. The symptom in the RTC Eclipse client is slightly different - the indicator can appear briefly and disappear when the focus is moved to other attribute.

I tested this in RTC 5.0.2 and could not find any defects similar to this. I think you can open a new defect for that.

P.S. There are two things that you can improve your code - 1. add modules "" and "" to the code otherwise it will not work in RTC Eclipse client. 2. The logic is flawed and the code should return an error when either of the timestamp values is null (unless you make them mandatory somewhere else).

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.