Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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.

0 votes


Accepted answer

Permanent link

 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

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 7,494
× 6,121
× 1,324

Question asked: Jul 13 '22, 11:25 a.m.

Question was seen: 898 times

Last updated: Jul 14 '22, 2:43 a.m.

Confirmation Cancel Confirm