EWM 7.0.2 - Best way to limit hours estimate across whole tool UI
Hi all
Can anyone recommend the best way to limit the amount of hours estimated against a single task that will work across the different UI elements? i.e. if someone is entering hours in a plan view, or in a standard work item view, or in quick planner, etc.
e.g. Work Item save won't work if the execution work item estimate is greater than 80 hrs.
Thanks,
Glyn
2 answers
I agree with Ralph - I would use a Validator in the Work Item Attribute Customisation and then attach it to the Estimate attribute. The Estimate attribute is of type Duration so you will need to create a Script based Validator as the built in decimal or integer ones can't be attached to the field.
Something like this will work. Duration is returned in milliseconds, so you'll need to multiply by an appropriate factor - I've made the maths explicit below:
dojo.provide("com.example.estimateTooBig.Validator");
dojo.require("com.ibm.team.workitem.api.common.Severity");
dojo.require("com.ibm.team.workitem.api.common.Status");
(function() {
const Severity = com.ibm.team.workitem.api.common.Severity;
const Status = com.ibm.team.workitem.api.common.Status;
dojo.declare("com.example.estimateTooBig.Validator", null, {
validate: function(attribute, workItem, configuration) {
return parseInt(workItem.getValue(attribute)) < (80 * 60 * 60 * 1000) ?
Status.OK_STATUS :
new Status(Severity["ERROR"], "That's way too big!!");
}
});
})();
Once you have attached the validator to the Estimate, you will also need to go into the Operation Behaviour section and add the Attribute Validation precondition in order for the validator to be evaluated and the error thrown upon Save
PS: You need to use the EWM Eclipse Client to do this