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

RTC script based validation

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);
        }
    }
});
})();

0 votes



One answer

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

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

Question asked: May 26 '16, 2:52 a.m.

Question was seen: 2,322 times

Last updated: May 30 '16, 2:57 a.m.

Confirmation Cancel Confirm