It's all about the answers!

Ask a question

Script based dependent list shows as "Retrieving" for ever


Uma venkata Lekkala (52819) | asked May 15 '15, 4:37 p.m.
Any one faced similar situation? I am testing the script based dependent values on my system (I know I can use dependent values type value set for this simple scenario, but this is a test to further advance code later). When I test in front end I just see "Retrieving" but no drop-downs for the dependent list. What is wrong with my code?

dojo.provide("org.example.workitems.providers.listbValueSet");

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

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

dojo.declare("org.example.workitems.providers.listbValueSet", null, {

    getValueSet: function(attributeId, workItem, configuration) {
   
        var lista= workItem.getValue(WorkItemAttributes.lista);
        var listbOptions= [];
       
        if ((lista === "lista.literal.l4")) {
             listbOptions.push("listb.literal.l2"); // 1
             listbOptions.push("listb.literal.l6"); // 2
             listbOptions.push("listb.literal.l8"); // 3
          
              }
        else if ((lista === "lista.literal.l2")) //alphabets
             {
              listbOptions.push("listb.literal.l4"); // a
              listbOptions.push("listb.literal.112"); // b
              listbOptions.push("listb.literal.l14"); // c
                       }
        else if ((lista === "lista.literal.l6"))
        {
          listbOptions.push("listb.literal.l16"); // $
              listbOptions.push("listb.literal.118"); // #
       
        }
     
        return listbOptions;
    }
});
})();

One answer



permanent link
Donald Nong (14.5k614) | answered May 17 '15, 8:33 p.m.
The below code is incorrect since "lista" is _not_ a built-in attribute.
var lista= workItem.getValue(WorkItemAttributes.lista); 
It should more likely be
var lista= workItem.getValue("lista"); 
Check the document carefully and do sufficient debugging with your codes.
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#ScriptBasedNotes
https://jazz.net/wiki/bin/view/Main/WorkItemsWebDebugging

Comments
Uma venkata Lekkala commented May 17 '15, 8:37 p.m.

 The name is ListA and the id is lista. Should I use id or name? 


Donald Nong commented May 18 '15, 3:00 a.m.

Check the Wiki linked above.

workItem An instance of a work item for which this script is being executed. This supports the following operations:
  • getValue(String attributeId) returns the value of the attribute with the specified id.


Uma venkata Lekkala commented May 21 '15, 10:13 p.m. | edited May 22 '15, 12:36 a.m.

This is how my code looks now. I modified an example script, Does any of this need to change SPECIFIC to my environment? If attribute id is lista, string attribute id should be lista or 'lista' or "lista"?


dojo.provide("org.example.workitems.providers.listbaValueSet");

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

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

dojo.declare("org.example.workitems.providers.listbaValueSet", null, {

    getValueSet: function(attributeId, workItem, configuration) {
    
        var lista= workItem.getValue(lista);
        var listbOptions= [];
        
        if ((lista === "lista.literal.l4")) {
             listbOptions.push("listb.literal.l2"); // 1
             listbOptions.push("listb.literal.l6"); // 2
             listbOptions.push("listb.literal.l8"); // 3
           
              }
        else if ((lista === "lista.literal.l2")) //alphabets
             {
              listbOptions.push("listb.literal.l4"); // a
              listbOptions.push("listb.literal.112"); // b
              listbOptions.push("listb.literal.l14"); // c
                       }
        else if ((lista === "lista.literal.l6"))
        {
          listbOptions.push("listb.literal.l16"); // $
              listbOptions.push("listb.literal.118"); // #
        
        }
      else 
        return listbOptions;
    }
});
})();


Donald Nong commented May 22 '15, 12:38 a.m.

You can use either single quotes or double quotes, as they work the same way. But it is incorrect to use lista without quotes, as it is the variable that you just declare and its value is null.

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.