Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes

Comments

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

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
 Have you configured the operational behavior?

0 votes

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

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,935
× 6,121
× 152

Question asked: Oct 03 '13, 7:06 a.m.

Question was seen: 7,509 times

Last updated: Oct 04 '13, 4:38 a.m.

Confirmation Cancel Confirm