It's all about the answers!

Ask a question

Description from script based validation is not working

Michael Besems (132) | asked Sep 19 '18, 3:21 a.m.
edited Sep 19 '18, 5:17 a.m. by Ralph Schoon (63.3k33646)
I can't seem to get my script based validation to work.

What I need?
When a new story is created a standard text is filled in the description field (Different text for Story & Defect, none for the rest).

What I've done:
- Script based validators are turned on
- Created new validator:
(function() {
   var WorkItemAttributes =;
   dojo.declare("com.example.common.MyClass", null, {
   getDefaultValue: function(attribute, workItem, configuration) {

   var WorkItemType = workItem.getValue(WorkItemAttributes.TYPE);

    if (WorkItemType == "defect") {
         return "I am a defect";
     return "I am no defect"; 
- Attached the new validator to the Description attribute

What I see:
- goto web interrface: Work item - Create Work item - Defect
- Description field remains empty

I at least expected to see something happening here.
At the very least the "I am no defect" if I got the type wrong or a visible error message somewhere.

Note: If I add a Default Value to the "Desription" attribute this does work (only same text for all work item types, hence why I went script based).

Thanks in advance

Accepted answer

permanent link
Ralph Schoon (63.3k33646) | answered Sep 19 '18, 5:16 a.m.

Did you search for any documentation before you tried that? 

You selected the template for a default value provider - which obviously does not work.

See and

Create a proper validator that returns what is needed AND configure the operation behavior 

No matter what presentation you choose to use, all attribute values will be validated when they are saved on the server if Attribute validation is configured as a precondition for saving [work item] in Team Configuration, Operation Behavior.
Also see last two chapters.

Michael Besems selected this answer as the correct answer

Ralph Schoon commented Sep 19 '18, 5:19 a.m.

Also note that a validator is not a Default value provider. You should try to be precise with what you ask. 

Michael Besems commented Sep 19 '18, 7:59 a.m.
Thanks that helped me find the answer.

I got the suggestion for this solution from:
But the link in that answer (just above the template) opens on a screen for a validator.
I should have paid more attention to the fact that this was just an example of <a> type of script based action.

Anyway, thanks again

Ralph Schoon commented Sep 19 '18, 8:12 a.m.

I guess you are looking for a default value then. 

Please note that there is very little information available (e.g. NOT necessary the type) on creation time. Also carefully read what is supported (and implying the limitations because what is not documented there is not supported). The workshop is more detailed. 

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.