How to validate a customized attribute value using another attribute value?
Accepted answer
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;
}
});
})();
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;
}
});
})();
Comments
[Example of refering other custom attributes]
https://jazz.net/forum/questions/122588/javascript-condition-based-on-value-of-custom-attribute
[Example of validation]
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_Based_Validation