It's all about the answers!

Ask a question

script-based customization getValue returns null (Newbie question)


david bettenhausen (324) | asked Jun 03 '13, 10:55 a.m.
edited Jun 03 '13, 10:56 a.m.
 Can't seem to use getValue() or WorkItemAttributes. How do I get these loaded? Is there a configuration someplace to point to these resources?

*****************************************************************************************
This first one works:
******************************************************************************************
dojo.provide("com.example.ValueProvider.basedonstate");

dojo.require("dojo.date");
dojo.require("dojo.date.stamp");

(function() {
    dojo.declare("com.example.ValueProvider.basedonstate", null, {

        getValue: function(attributeId, workItem, configuration) {
          var currentDate= new Date();
          var Datestring= dojo.date.stamp.toISOString(currentDate, {milliseconds:true, zulu:true});   
          return "Date " + Datestring ;
        }

    });
})();

*********************************************************************************************
This Does not:
*********************************************************************************************
dojo.provide("com.example.ValueProvider.basedonstate");

dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");

(function() {
    dojo.declare("com.example.ValueProvider.basedonstate", null, {

        getValue: function(attributeId, workItem, configuration) {
        var typeString =   + workItem.getValue(WorkItemAttributes.TYPE);    
        return "Type: " + typeString ;
    }
    });
})();

2 answers



permanent link
sam detweiler (12.5k6195201) | answered Jun 03 '13, 11:03 a.m.
here is one of my condition scripts

<code>
dojo.provide("com.xx.defect.resolution.Condition");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
    dojo.declare("com.xx.defect.resolution.Condition", null, {

        matches: function(workItem, configuration)
        {
           var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
           var rc = false;
           var workitemtype = workItem.getValue(WorkItemAttributes.TYPE);

           console.log(workitemtype);

           if( workitemtype ==="defect" )
           { 
              var state= workItem.getValue(WorkItemAttributes.STATE);
              console.log(state);

              if(state === "3" )
              {
                 var resolution = workItem.getValue(WorkItemAttributes.RESOLUTION);
                 console.log(resolution);
                 if(resolution === "3" )
                 {
                   var classification = workItem.getValue("com.xx.fribblelist");
                        console.log(typeof(classification))
                    if(classification === "" )
                    {
                        /*return (state === "3" || state === "4"); // Resolved or Verified stat
                        rc= true;
                    }
                    rc = true;
                 }
              }
           }
           return rc;
        }
    });
})();
</code>

Comments
david bettenhausen commented Jun 03 '13, 11:19 a.m.

I don’t seem to be able access getValue or WorkItemAttributes. I suspect there is someplace where the paths to these js files needs to be set but: 

1. I don’t know where and;
2.    I don’t know if I have the access (jazzProgAdmin).


permanent link
david bettenhausen (324) | answered Jun 03 '13, 1:02 p.m.
needed the line: 

var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes ;

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.