Attribute validation is not working - please help
Hello,
I am trying to use condition - validator approach for working with required attributes in my application. In condition, I am using check for state and action to set attributes as required and this is working fine. In validator, I am checking if the field value is unassigned or blank, and in that case, I am throwing an error message
like - return new Status(Severity["ERROR"], message);
The validator is firing correctly and on error, I am able to see a red cross mark at the attribute to which I have attached the validator. On mouse over that cross mark, I can see right eror message.
The issue is, in spite of throwing this error message, the defect is being saved to next state.
I have also added the pre-condition of attribute validation to Save Work Item (server) for Everyone. I am configuring Operation Behavior section of Team Configuration.
I have only one team area in my project area.
Please help to resolve this situation. I really appreciate your advice.
Accepted answer
There was an empty script which was showing errors in the console log. I removed it from Links.
Now, the work item is not saved with validation errors.
6 other answers
From your description it sounds as if everything is set up correctly and should work.I think I remember there were issues with certain versions of RTC where the save was not blocked.
Comments
Hello Sir,
Thanks a lot for your guidance.
RTC version for both my server and client is 4.0.5. Can the issue be associated with this particular version? Please advise.
I just tried a simple regular expression validator on 4.0.5 on the description field.
Configured correctly, it works as expected and prevents the save.
I tried with a script and the save was not prevented.
Well, after playing around with it, closing the client and web session, and retrying, it works with a script too.
In the validator, I am throwing an error message like - return new Status(Severity["ERROR"], message);
The validator is firing correctly and on error, I am able to see a red cross mark at the attribute to which I have attached the validator. On mouse over that cross mark, I can see right eror message.
The issue is, in spite of throwing this error message, the work item is being saved to next state.
I have also added the pre-condition of attribute validation to Save Work Item (server) for Everyone. I am configuring Operation Behavior section of Team Configuration.RTC Version: 5.0.1
https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=337340
Comments
I created this basic script:
/*********** * Licensed Materials - Property of IBM * (c) Copyright IBM Corporation 2011. All Rights Reserved. * * Note to U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule * Contract with IBM Corp. ***********/ dojo.provide("com.example.Validator");dojo.require("com.ibm.team.workitem.api.common.Severity"); dojo.require("com.ibm.team.workitem.api.common.Status");
(function() {
var Severity= com.ibm.team.workitem.api.common.Severity; var Status= com.ibm.team.workitem.api.common.Status;
dojo.declare("com.example.Validator", null, { validate: function(attribute, workItem, configuration) { return new Status(Severity["ERROR"], "Validation failed"); } });
})();
Then I configured the attribute (description) and the operational behavior.
It works nicely for me in 5.0.1. So I have to assume you do something wrong.
Thanks for spending time to debug this issue.
First thing I did is copied your script and configured Description attribute with this validator and checked.
The work item is saved, even if there a validation error on the description.
So, pre-condition is the problem for me. That is where I am going wrong.
Could you please let me know the steps you followed to enable the pre-condition in 5.0.1
Alejandro,
You can also try this basic script in your environment and see if it works for you.