It's all about the answers!

Ask a question

dojo Script is validating but allowing to save the workitem. How to rectify this.


Pavan M (3915) | asked Apr 16 '21, 2:31 a.m.

 Hii,

I had created a validation script in dojo for Enumerationlist(Check list Enumeration). When I select "b" in Arribute of "Testf" then Attribute "Testr" need to become mandotry. I can able to make it as mandatory but when I save the workitem without filling mandotry filed(Testr) it is getting saved. I am not understanding where change the code. Below is my code and when I uncheck "b" then that "*" mark need to go but it is not refreshing automatically. If anyone knows kindly suggest me.


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
dojo.provide("org.organization.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("org.organization.Validator", null, {
        validate: function(attribute, workItem, configuration) {
var severity= configuration.getChild("parameters").getStringDefault("severity", Severity.ERROR.name);
        var message= configuration.getChild("parameters").getStringDefault("message", "");
    var selectedValues = workItem.getValue("testf");
    var specify = workItem.getValue("testr");
  
   
if(selectedValues!==null){
if(selectedValues!==undefined){

for (var i=0; i < selectedValues.length; i++) {
console.log("-----###--------"+selectedValues[i].label);
if(selectedValues[i].label!=="b"){
console.log("value  --- 111 "+selectedValues[i].label);


return Status.OK_STATUS;

}else {
if((selectedValues[i].label=="b")&&(specify=="")){
console.log("Entered here2");
            return new Status(Severity.ERROR, message);}
        }

}

       
}    }
  



        }
    });
})();

Thank you,
Regards,
Pavanm



Be the first one to answer this question!


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.