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

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

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.

0 votes


Accepted answer

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

2 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
× 10,943

Question asked: Nov 17 '15, 3:09 a.m.

Question was seen: 1,734 times

Last updated: Nov 17 '15, 7:32 p.m.

Confirmation Cancel Confirm