Problem with condition based script
I have a Condition based script. Basically, for a specific WI type, I want to validate a field, and depending on the value selected on that field, I need to make another field mandatory.
My script is basically working right now, but I found another implication of this, and would like to know how to solve.
My problem is that in the way that you configure a condition script, it is not tied to a specific work item, so it runs for every work item type. The first thing that comes to my mind is a performance issue: I'm not facing the performance issue now because I do not have too much conditions implemented, but wondering if this will be a problem in the near future.
What I noticed with this implementation -and here is the deal- is that, as it works for all the work item types, and the attribute that I'm looking for is not present on all the work items, it exists with "return false". This makes all the red asterisks of mandatory fields to dissapear from my UI.
I still get the errors for the remaining fields, but one by one, and no red asterisk.
Is there anything that I should do different on this script or any kind of workaround to my problem? Thanks in advance!
Claudia
dojo.provide("org.example.workitems.providers.WPIOtherChecklists");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("org.example.workitems.providers.WPIOtherChecklists", null, {
matches: function(workItem, configuration) {
var checklists = workItem.getValue("com.ibm.gbs.workitem.wpi.checklists");
if ((checklists == null) || (checklists.indexOf("wpi.checklists.literal.l25") === -1) ) {
// WPI >> Checklists DOES NOT contain the value 'Other' selected
return false;
} else {
// WPI >> Checklists contains the value 'Other' selected
return true;
}
}
});
})();
My script is basically working right now, but I found another implication of this, and would like to know how to solve.
My problem is that in the way that you configure a condition script, it is not tied to a specific work item, so it runs for every work item type. The first thing that comes to my mind is a performance issue: I'm not facing the performance issue now because I do not have too much conditions implemented, but wondering if this will be a problem in the near future.
What I noticed with this implementation -and here is the deal- is that, as it works for all the work item types, and the attribute that I'm looking for is not present on all the work items, it exists with "return false". This makes all the red asterisks of mandatory fields to dissapear from my UI.
I still get the errors for the remaining fields, but one by one, and no red asterisk.
Is there anything that I should do different on this script or any kind of workaround to my problem? Thanks in advance!
Claudia
dojo.provide("org.example.workitems.providers.WPIOtherChecklists");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("org.example.workitems.providers.WPIOtherChecklists", null, {
matches: function(workItem, configuration) {
var checklists = workItem.getValue("com.ibm.gbs.workitem.wpi.checklists");
if ((checklists == null) || (checklists.indexOf("wpi.checklists.literal.l25") === -1) ) {
// WPI >> Checklists DOES NOT contain the value 'Other' selected
return false;
} else {
// WPI >> Checklists contains the value 'Other' selected
return true;
}
}
});
})();