Script-based validator Sample
I wanted to share an example of something I recently did in case someone else wants to use it for their own purposes and build from it.
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 == "com.ibm.team.apt.story.idea") { return Status.OK_STATUS; } else { if (pts == "0") { return new Status(Severity[severity], messagePts); } else { return Status.OK_STATUS; } } } }); })(); Then, in the Eclipse client > a scrum PA, I created a script-base validator and added the parameters to it. <validator id="com.ibm.team.workitem.valueproviders.VALIDATOR._ielBwEDAEeKw0MAxi0hItg" name="ptsValidator" providerId="com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider"> <script class="org.example.PtsValidator" path="/workitem/scripts/common/ptsValidator.js"/> <parameters messagePts="Not in new state...Invalid story point value" ptsAttrID="com.ibm.team.apt.attribute.complexity" severity="ERROR"/> </validator> |
One answer
The above validator script checks when changing workflow state to any states other than the 'New' state, if the story point value is 0 pt, it will display the message "Not in new state...Invalid story point value". This script does not check for any specific work item type.
|
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.
Comments
It would be useful if you described the use case for this so that people could search for it.