It's all about the answers!

Ask a question

How to validate a customized attribute value using another attribute value?


Yasuyuki Tominaga (314) | asked Nov 17 '15, 3:09 a.m.
edited Nov 17 '15, 5:11 a.m.
How to validate an customized attribute value using other attribute values?

For example, I'd like to prevent user from saving attribute "rekkyo1" value when other attributes "rekkyo2" and "rekkyo3" have invalid values.

Accepted answer


permanent link
Yasuyuki Tominaga (297216) | answered Nov 17 '15, 3:12 a.m.
edited Nov 17 '15, 7:32 p.m.
Make a script based validator such as this example code:

dojo.provide("com.example.Validator");
dojo.require("com.ibm.team.workitem.api.common.Severity");
dojo.require("com.ibm.team.workitem.api.common.Status");

(function() {

var Severity= com.ibm.team.workitem.api.common.Severity;
var Status= com.ibm.team.workitem.api.common.Status;

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

        validate: function(attribute, workItem, configuration) {
            var rekkyo1 = workItem.getValue("rekkyo1");
            var rekkyo2 = workItem.getValue("rekkyo2");
            var rekkyo3 = workItem.getValue("rekkyo3");
            console.log("HERE IS rekkyo1 VALUE" + " " + rekkyo1);
            console.log("HERE IS rekkyo2 VALUE" + " " + rekkyo2);
            console.log("HERE IS rekkyo3 VALUE" + " " + rekkyo3);
            
            if (rekkyo2 == 'severity.literal.l1' || rekkyo3 == 'severity.literal.l1'){
                return new Status(Severity["ERROR"], "Validation failed. Please input valid values in rekkyo2 and rekkyo3");
            }
            return Status.OK_STATUS;
        }
    });
})();
Yasuyuki Tominaga selected this answer as the correct answer

Your answer


Register or to post your answer.