How to avoid saving a work item if a custom work item attribute condition is not satisfied?
Hello,
I am using Rational Team Concert 5.0.2.
I am not able to configure an attribute condition which prevents from saving a work item if it is not held.
I have made the following customizations in my project area:
1) I have added a new attribute (with a name "Team") of the work item type "Task" in Project Configuration --> Configuration Data --> Work Items --> Types and Attributes
Its type is "Category".
2) I have added a script based condition (named "VerifyTeam") in Project Configuration --> Configuration Data --> Work Items --> Attribute Customization:
2.1) Attachment Path: /workitem/scripts/common/verifyteam.js
2.2) Class Name: com.visteon.team.Condition
2.3) Script (if the attribute named "Team" does not contain the prefix "team_" then the script returns false):
dojo.provide("com.visteon.team.Condition");
dojo.require("com.ibm.team.workitem.attribute.category");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.visteon.team.Condition", null, {
matches: function(workItem, configuration) {
var team = workItem.getLabel("com.visteon.team.workitem.attribute.category");
var position = team.indexOf("team_");
if ( position === 0 ) {
return true;
}
return false;
}
});
})();
3) I have added a new precondition for the Work item operation "Work Items -->Save Work Item (server)" for the role "Everyone" in Team Configuration --> Operation Behavior:
-- Attribute Validation
I'd expect that I am not able to save my work item of a type "Task" if the value of the "Team" attribute does not start with the prefix "team_". Unfortunately no matter what is the value of this attribute I am able to save the work item.
As a comparison I added a similar validator by changing the script a little bit and it works.
Can you please help me find what I am doing wrong?
For information, the validator works only in the web client, but not in the Eclipse client.
Thanks in advance for your help!
Regards,
Krasimir Malchev
Visteon Electronics Bulgaria
Accepted answer
-
Required Attributes For Condition
- Read-Only Attributes For Condition
If the condition specified attributes as required it prevents saving the work item if there is no value.
Validators are a completely different thing and can be used with the built in Attribute Validation Advisor / precondition
- Attribute Validation
It prevents saving only if the severity of the Validator is set to Error - or the Script returns severity error.
This has worked for me in both UI's. See the workshop Process Enactment Workshop for the Rational solution for Collaborative Lifecycle Management in Lab 4 and 5.