validation attribute based on workitem state
Hi All,
i need validate attribute "Performance" on Closed State. On Closed State the "Performance" attribute must be 100 if not workitem cannot save and show message error.
i have created one script, but my script not running correctly.
PtsValidator.js
dojo.provide("org.example.PtsValidator");
dojo.require("com.ibm.team.workitem.api.common.Severity");
dojo.require("com.ibm.team.workitem.api.common.Status");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(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;
var DateValidator = dojo.declare("org.example.PtsValidator", null, {
validate: function(attributeId, workItem, configuration) {
// Get the configuration parameters about the severity and error message of this validator
var severity= configuration.getChild("parameters").getStringDefault("severity", Severity.ERROR.name);
var messagePts= configuration.getChild("parameters").getStringDefault("messagePts", "");
// Get the story points attribute from the configuration
var ptsAttr = configuration.getChild("parameters").getStringDefault("ptsAttrID", "");
var pts = workItem.getValue(ptsAttr);
// Get the current state value
var state= workItem.getValue(WorkItemAttributes.STATE);
if (state == "task_workflow.state.s3") {
if (pts == "0") {
return new Status(Severity[severity], messagePts);
} else {
return Status.OK_STATUS;
}
} else {
return Status.OK_STATUS;
}
}
});
})();
in the Process Configuration Source:
<validator id="com.ibm.team.workitem.valueproviders.VALIDATOR._1lp04CwTEeOL1d4DWK6Zsg" name="Validator" providerId="com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider">
<script class="org.example.PtsValidator" path="/workitem/scripts/common/PtsValidator.js"/>
<parameters messagePts="Validator attribute must be 100 on Closed State" ptsAttrID="com.ibm.team.workitem.attribute.validator" severity="ERROR"/>
</validator>
please advise
Thank u
One answer
Have you configured the operational behavior?
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Oct 03 '13, 8:47 a.m.julius sahat
Oct 04 '13, 4:38 a.m.