It's all about the answers!

Ask a question

Validator to check and throw an error message when Time Spent attribute value is greater than Estimate attribute value


Divya _ (254) | asked Jul 13 '22, 11:25 a.m.
Hello Team,

We need an error message to be triggered when the Time Spent Value is entered greater than the Estimate/Correction Value and the WI should not be allowed to Save.
I tried writing a script to implement this validation but it is not working as expected. It is not validating the condition when time spent is greater than estimate and throwing the error message irrespective of the value in time spent.
(Version: 7.0.2)

Could you please help and let me know if I'm missing something?


dojo.provide("com.bosch.rtc.js.client.workflow.timevalidator");
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.timeSpent");
dojo.require("com.ibm.team.workitem.api.common.duration");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
    var doDebug = true;
    
     Status = com.ibm.team.workitem.api.common.Status,
     Severity = com.ibm.team.workitem.api.common.Severity,
     timeSpent = "timeSpent",
     estimate = "duration",
     WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes,
    
     dojo.declare("com.bosch.rtc.js.client.workflow.timevalidator", null, {
     validate: function(attribute, workItem, configuration) {                     
if((timeSpent==estimate)&&(timeSpent<=estimate)){
return Status.OK_STATUS;
        } else {
            return new Status( Severity["ERROR"], " Time Spent value is greater than the Estimate. Please correct the Estimate value.");
        }
    
                }
           
     });           
     })();


Thanks in advance.

Accepted answer


permanent link
Ralph Schoon (63.1k33646) | answered Jul 14 '22, 2:43 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 Several suggestions. 

  1. https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript shows definition for a the attribute ID's including the ones you want.
  2. Use console.log. E.g. console.log("Estimated Invest: " + estimatedInvest); 
  3. The log data is in \JazzTeamServer\server\liberty\servers\clm\workarea\org.eclipse.osgi\92\data\temp\default_node\SMF_WebContainer\ccm\ccm\eclipse\workspace.metadata.log if you use Liberty Profile.
  4. More tips in https://jazz.net/library/article/1093 
  5. I assume you get a string back, so do not assume >= works.
  6. You need to configure the Attribute Validation Precondition for validation to do anything.

Divya _ selected this answer as the correct answer

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.