It's all about the answers!

Ask a question

Date Validation on RTC attributes

Ashwath G (6623550) | asked Mar 02 '15, 1:32 p.m.
edited Mar 02 '15, 1:36 p.m.

We have a requirement to implement the date validation on RTC date attributes.

There are two custom date attributes say Analysis Start Date and Analysis End Date . Never the End Analysis Date should be lesser than Start Date. And it should throw the error if the above condition is not met while save operation on WI.
We wrote a Validation script and created a validator applied on the attribute . But its not working , its throwing an error message on end date if date is less than start date , but it is able to save the Workitem.

Could you please verify the below code and let us know how to throw error and not to save WI.


dojo.require(""); // We need the date class from Dojo to compare two dates
dojo.require(""); // We need the stamp class to work with ISO date strings

(function() {
var Severity =;
var Status =;
var WorkItemAttributes=;

dojo.declare("", null, {

    validate: function(attributeId, workItem, configuration) {
           var severity = "ERROR";
            var message = "Start Date should be less than End Date";
  // Get the begin date attribute from the configuration and make a Date object from it
       var beginDateId = workItem.getValue("plannedanalstart");
        var beginDate =;
        // Get the current attribute's value and make a Date object from it
        var endDateId = workItem.getValue("plannedanalend");
        var endDate =;
        // Compare the two dates and make sure endDate is not earlier than beginDate
        if (, beginDate) >= 0) {
            return Status.OK_STATUS;
        } else {
            return new Status(Severity[severity], message);

Thank you...!


One answer

permanent link
Ralph Schoon (63.1k33646) | answered Mar 05 '15, 4:42 a.m.
Please see on how to configure the operational behavior to prevent saving on error.

I can't see any obvious problem with the script.

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.