It's all about the answers!

Ask a question

getValueSet script is not returning the values as expected when one attribute dependency is set on two other attributes


Chandrasekar Muthukrishnan (32112) | asked Jul 10 '20, 2:12 a.m.

RTC 6.0.6.1


There are three enumeration attributes in a project area

Platform Name1 with id  listplatformname1
Component Type1 with id componenttype1
Component Name1.

We are trying to do attribute customization so in component name1 field not all the defined enumerations are displayed. Based on the selection of Platform Name1 field and Component Type1 field selection, few enumeration values only should be listed in the Component Name1 field. We created a dojo script for it. But it is not working as expected.

The script 

dojo.provide("com.visteon.workitems.providers.componentname1");
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("com.visteon.workitems.providers.componentname1", null, {

    getValueSet: function(attributeId, workItem, configuration) {
    
        var platformname1= workItem.getValue("listplatformname1");
var componenttype1= workItem.getValue("componenttype1");
        var componentname= [];
        
//MediaTek
        if (platformname1=="com.visteon.hwps.enum.platformname.literal.l7")
{
//SOC-GIP
if (componenttype1=="com.visteon.hwps.enum.comptype.literal.l4")
(
  componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
  componentname.push("com.visteon.hwps.enum.componentname.literal.l4");
)
//VIP
else if (componenttype1=="com.visteon.hwps.enum.comptype.literal.l7")
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l6");
}
//Memory
else if (componenttype1=="com.visteon.hwps.enum.comptype.literal.l6")
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l8");
componentname.push("com.visteon.hwps.enum.componentname.literal.l10");
componentname.push("com.visteon.hwps.enum.componentname.literal.l12");
}
//Power Strategy
else if (componenttype1=="com.visteon.hwps.enum.comptype.literal.l8")
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l14");
}
//Display Sizes
else if (componenttype1=="com.visteon.hwps.enum.comptype.literal.l9")
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l16");
}
//Network Interfaces
else if (componenttype1=="com.visteon.hwps.enum.comptype.literal.l10")
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l18");
componentname.push("com.visteon.hwps.enum.componentname.literal.l20");
}
//Display Interface
else if (componenttype1=="com.visteon.hwps.enum.comptype.literal.l11")
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l22");
}
//Camera Input
else if (componenttype1=="com.visteon.hwps.enum.comptype.literal.l12")
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l24");
}
//Tuner
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l13')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l26");
}
//BTWifi
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l14')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l28");
}
//PCB
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l15')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l30");
}
//Others
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l18')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l85");
}
else
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
}
//SmartCore QC6150 (W601)
else if (platformname1=='com.visteon.hwps.enum.platformname.literal.l8')
{
//SOC-GIP
if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l4')
(
  componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
  componentname.push("com.visteon.hwps.enum.componentname.literal.l32");
)
//VIP
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l7')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l34");
}
//Memory
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l6')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l36");
componentname.push("com.visteon.hwps.enum.componentname.literal.l38");
}
//Power Strategy
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l8')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l40");
}
//Display Sizes
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l9')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l42");
}
//Network Interfaces
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l10')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l44");
componentname.push("com.visteon.hwps.enum.componentname.literal.l46");
}
//Display Interface
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l11')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l48");
}
//Camera Input
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l12')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l50");
        componentname.push("com.visteon.hwps.enum.componentname.literal.l52");
}
//Tuner
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l13')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l54");
}
//BTWifi
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l14')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l56");
}
//PCB
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l15')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l58");
componentname.push("com.visteon.hwps.enum.componentname.literal.l60");
}
//Others
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l18')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l85");
}
else
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
}
}
//Einstein 3.5
else if (platformname1=='com.visteon.hwps.enum.platformname.literal.l4')
{
//SOC-GIP
if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l4')
(
  componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
  componentname.push("com.visteon.hwps.enum.componentname.literal.l62");
)
//VIP
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l7')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
}
//Memory
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l6')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l64");
componentname.push("com.visteon.hwps.enum.componentname.literal.l67");
componentname.push("com.visteon.hwps.enum.componentname.literal.l69");
}
//Power Strategy
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l8')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l71");
}
//Display Sizes
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l9')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l16");
}
//Network Interfaces
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l10')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l75");
componentname.push("com.visteon.hwps.enum.componentname.literal.l77");
componentname.push("com.visteon.hwps.enum.componentname.literal.l79");
componentname.push("com.visteon.hwps.enum.componentname.literal.l81");
componentname.push("com.visteon.hwps.enum.componentname.literal.l81");
}
//Display Interface
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l11')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l83");
}
//Camera Input
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l12')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
}
//Tuner
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l13')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
}
//BTWifi
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l14')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
}
//PCB
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l15')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l30");
}
//Others
else if (componenttype1=='com.visteon.hwps.enum.comptype.literal.l18')
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
componentname.push("com.visteon.hwps.enum.componentname.literal.l85");
}
else
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
}
}
else 
{
componentname.push("com.visteon.hwps.enum.componentname.literal.l2"); 
}
        return componentname;
    }
});
})();


But the script is not working and all the values in the enum are displayed in the field.
Is there any issue in the script?

3 answers



permanent link
Dinesh Kumar B (4.0k413) | answered Jul 10 '20, 4:33 a.m.
JAZZ DEVELOPER
some quick things to check... try using === (triple equals) for comparison vs == (double equals) used above., triple equals is more accurate comparison...

secondly., in your comparison, you are using single quotes at places and double quotes at some other places... I would suggest values to be enclosed in double quotes while comparing...

and., you may want to add console.log statements to see what is the getValue returning., so as to be sure what is being returned as the literal value.,

lastly., ensure the attribute associated with the component Name1 attribute has the script set correctly and also has the dependencies on both the platform and component type..

permanent link
Ralph Schoon (57.2k23642) | answered Jul 10 '20, 5:23 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Unfortunately there is a lack of information about the type of the three(?) attributes involved. They could be of type enumeration or enumerationList. " all the values in the enum are displayed in the field" hint the latter.
 
Given that consider the following:

  1. You created a value set
  2. A value set only returns the valid selections for an attribute
  3. A value set does not delete anything from an attribute of type enumerationList, it only allows to select choices that can be added.
  4. Your script runs correctly if you have a new work item with an empty attribute, the attributes that should be used for filtering have valid values. when setting the dependent list attribute, you should only be able to select the values your value set returns for selection. You have to pick the ones you want to set.

permanent link
Chandrasekar Muthukrishnan (32112) | answered Jul 14 '20, 8:40 a.m.

 Thanks Dinesh and Ralph for your comments. 
There was a syntax issue. In one if clause I have used ( instead of { . That is the problem it was not working.
Also I have modified the == with ==== .


Your answer


Register or to post your answer.