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
Hi Ralph,
Thanks for your response
i have configured the operation behavior, i have add "validation attribute"
i will discribe my goal:
in Workitem Task i have 4 state is New, In Progress, Closed and Reopened.
in Closed state the validator attribute must be 100 if not WI cannot save.
the validator is running, the problem is in all state the attribute cannot '0'.
can u help me to check my script
Thank u
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Oct 03 '13, 8:47 a.m.Sorry, now I see the other if. I would suggest to debug the script.
julius sahat
Oct 04 '13, 4:38 a.m.hi Ralp,