It's all about the answers!

Ask a question

Script Based Validation with Attribute Validation is not work


Yu Pu (1112) | asked Nov 24 '15, 10:56 p.m.
edited Nov 25 '15, 2:32 a.m. by Ralph Schoon (63.3k33646)
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

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



permanent link
Kohji Ohsawa (5951310) | answered Nov 25 '15, 12:02 a.m.
JAZZ DEVELOPER
Hi Yu,

I just want to make sure. Have you enabled script based customize on ccm/admin advanced property page? If so, can you put some console.log ("test") to know if it is executed or not.

permanent link
Ralph Schoon (63.3k33646) | answered Nov 25 '15, 2:34 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Nov 25 '15, 2:37 a.m.
 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.

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.