Script based dependent list shows as "Retrieving" for ever
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
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
The name is ListA and the id is lista. Should I use id or name?
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.
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;
}
});
})();
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.