It's all about the answers!

Ask a question

Attribute validation is not working - please help


Mahasweta Bagchi (645) | asked Feb 19 '14, 11:17 p.m.

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


permanent link
Anitha Nalluri (311010) | answered Mar 13 '15, 2:44 a.m.
I found an issue in my environment and after resolving that, attribute validation is working fine.

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.
Ralph Schoon selected this answer as the correct answer

6 other answers



permanent link
Ralph Schoon (63.1k33646) | answered Feb 20 '14, 2:34 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
We described how this works here: https://jazz.net/library/article/1093 (Lab 4 and 5)

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
Mahasweta Bagchi commented Feb 20 '14, 2:58 a.m.

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.


Ralph Schoon commented Feb 20 '14, 3:06 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Ralph Schoon commented Feb 20 '14, 3:22 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I tried with a script and the save was not prevented.


Ralph Schoon commented Feb 20 '14, 3:34 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Well, after playing around with it, closing the client and web session, and retrying, it works with a script too.


permanent link
Anitha Nalluri (311010) | answered Mar 05 '15, 10:07 a.m.
Hello, I have the same problem.

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

permanent link
Alejandro Gay (1168) | answered Mar 05 '15, 2:42 p.m.
RTC 5.01 here, same problem, I have the validator working properly, I have the attribute validation precondition, the validation error message is displayed but workitem can be saved despite of the invalid field, I have logged bug already on this aspect

https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=337340



Comments
Ralph Schoon commented Mar 06 '15, 2:49 a.m. | edited Mar 06 '15, 2:50 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


permanent link
Anitha Nalluri (311010) | answered Mar 06 '15, 5:51 a.m.
Hello Ralph,

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.

permanent link
Alejandro Gay (1168) | answered Mar 06 '15, 11:07 a.m.
Yes. not working in mine either

permanent link
Anitha Nalluri (311010) | answered Mar 13 '15, 5:24 a.m.
I am on RTC Version 5.0.1 and its all fine here.

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.