Script Based Validation with Attribute Validation is not work
I trying to wirte a Script Based Validation.with precondition Attribute Validation.it will check if the value is vaild while save the workItem.but is seems the Attribute Validation is not work.
Below is my step:
1.Create a new Script-based validator. Use the following Javascript
Why the Attribute Validation is not work and prevent me save and return error message?
Can you give some ideas?thanks.
Below is my step:
1.Create a new Script-based validator. Use the following Javascript
dojo.provide("com.example.Validator"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dojo.declare("com.example.Validator", null, { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
validate: function(attribute, workItem, configuration) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (workItem.getValue(WorkItemAttributes.CREATOR) === workItem.getValue(WorkItemAttributes.OWNER)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Status.OK_STATUS; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new Status(Severity.ERROR, "Pls Keep them same" );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})();
2.Add the Attribute Validation pre-condition for the Save Work Item(server) operation in Team Configuration > Operation Behavior. 3.Assign this validator to the Owned By attribute in Work Items > Types and Attributes.adding dependencies on the Creator. Then save and open a workItem. When do the test.if the CREATOR is different from OWNER.it will share error message in page. but when save.it will save sccessful. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Why the Attribute Validation is not work and prevent me save and return error message?
Can you give some ideas?thanks.
2 answers
Also verry common is to configure the operational behavior incorrect. The rules that apply are: Process behavior lookup in Rational Team Concert 2.0
The screenshot I can see as moderator, shows the validation works, as it shows the error markup. so I am not sure what happens.