It's all about the answers!

Ask a question

Script for an enumeration attribute of radio button type validation is not working


Ashwath G (6623951) | asked Jun 27 '19, 8:04 a.m.
edited Jun 27 '19, 8:37 a.m.

 Hi,


A script for making an enumeration attribute of radio button type required & validate is not working. Scope of the script is to validate if the attribute holds value "Disabled" in a state , if "enabled" should throw the error upon action to move to next state. This attribute also a required attribute in that state & should hold a specific enumeration value.

Where i tried with a  conditional script and a validation script. None are working and nothing it writes to log as well. Please review if anything is wrong with scripts.

And is it a good idea to have separate scripts for "required Attribute" condition and for "Validation" of a value ?

Conditional Script :

dojo.provide("com.ibm.team.workitem.ldapactioncheck"); 
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); 
dojo.require("com.ibm.team.workitem.api.common.Status");


(function() { 
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes; 

dojo.declare("com.ibm.team.workitem.ldapactioncheck", null, { 


matches: function(workItem, configuration) { 

        var state= workItem.getValue(WorkItemAttributes.STATE);
        var action = configuration.getWorkflowAction(); 
        console.log(" action is = " +act); 
var ladp = workItem.getValue(WorkItemAttributes.ldap);
        console.log(typeof(ldap))
if (state === "change-user-id.workflow.service.clm.ikea.com.state.s5") {
     if (action === "change-user-id.workflow.service.clm.ikea.com.action.a4" && ldap == "ldap.literal.l2") { 
// action is  
console.log(" action is preperation complete---true"); 

return true; 
 }
console.log(" action is preperation complete----false"); 
return false; 
   
    }
           
    }); 
})(); 

Validation Script:

This is the validation script for the same requirement.

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

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

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

        validate: function(attributeId, workItem, configuration) {
       
      var severity = configuration.getChild("parameters").getStringDefault("severity", Severity.ERROR.name);
      var message = configuration.getChild("parameters").getStringDefault("message", "");
      var state= workItem.getValue(WorkItemAttributes.STATE);
      var Type = workItem.getValue(WorkItemAttributes.TYPE);
      var ldap = workItem.getValue("ldap");      
           

// name="Preparation Complete"    id="change-user-id.workflow.service.clm.ikea.com.action.a4"

if(Type === "changeuserid.service.clm.ikea.com"){
if (state === "change-user-id.workflow.service.clm.ikea.com.state.s5"){

console.log("testtest111");
if (ldap == "ldap.literal.l2"){
console.log("Ldap Value is Enabled");  
 return new Status(Severity[severity], message); 
}
}
        }  
        console.log("Ldap is Disabled")
        return Status.OK_STATUS;
           
        }
    });
})();



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.