It's all about the answers!

Ask a question

RTC script based validation


Akshay Panchakshari (37429) | asked May 26 '16, 2:52 a.m.
edited May 26 '16, 3:01 a.m.

I have created a custom validatior to validate the dates. The scritp works fine. But the error message shown when the validation fails , it disappears when that date field goes out of focus. I want the error message to keep showing until the user enters the correct date ,how to accomplish this ? below is my validation script :

dojo.provide("org.example.DateValidator");

dojo.require("com.ibm.team.workitem.api.common.Severity");
dojo.require("com.ibm.team.workitem.api.common.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("org.example.DateValidator", null, {

    validate: function(attributeId, workItem, configuration) {
         console.log("hi");
        // Get the configuration parameters about the severity and error message of this validator
        var severity= configuration.getChild("parameters").getStringDefault("severity", Severity.ERROR.name);
        var message= configuration.getChild("parameters").getStringDefault("message", "");

  var dateRequiredBy=dojo.date.stamp.fromISOString(workItem.getValue(WorkItemAttributes.DUE_DATE));
  
        // Get the current attribute's value and make a Date object from it
  var extendedDate=dojo.date.stamp.fromISOString(workItem.getValue(attributeId));
        console.log(dateRequiredBy);
  console.log(extendedDate);
  
        // Compare the two dates and make sure extendedDate is not earlier than dateRequiredBy
  //If the dateRequiredBy > extendedDate = +ve else -ve
        if (dojo.date.compare(dateRequiredBy, extendedDate) <= 0) {
            return Status.OK_STATUS;
        } else {
            return new Status(Severity[severity], message);
        }
    }
});
})();

One answer



permanent link
Ralph Schoon (63.3k33646) | answered May 30 '16, 2:57 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
As far as I know all the script validator can do is return the state. The UI works as the UI works and displays the information returned as it pleases. You have no control on that.

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.