It's all about the answers!

Ask a question

validation attribute based on workitem state


julius sahat (2511116) | asked Oct 03 '13, 7:06 a.m.
 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

Comments
Ralph Schoon commented Oct 03 '13, 8:47 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Sorry, now I see the other if. I would suggest to debug the script.  


julius sahat commented Oct 04 '13, 3:58 a.m. | edited Oct 04 '13, 4:38 a.m.

hi Ralp,


i have add one line in script to test the script:
alert('Status = ' + state + '.');

after i test in browser the Status is null

please advise how to get WI Status?

Thanks 

One answer



permanent link
Ralph Schoon (63.1k33646) | answered Oct 03 '13, 8:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
 Have you configured the operational behavior?

Comments
julius sahat commented Oct 04 '13, 12:24 a.m.

 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

Your answer


Register or to post 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.