It's all about the answers!

Ask a question

Multiple dependent attributes in RTC value set


Deepali Deshmukh (8913759) | asked Apr 25 '16, 3:03 a.m.
edited Apr 26 '16, 9:11 a.m.
  Hi all,

I am trying to create dependent attributes in RTC value set. It is possible to fetch the values from a XML file to a field. Depending upon the value in the field we can populate its dependent value from the Xml file into another field. This can be done using HTTP filter value set using appropriate X-path expression . 

I want to have similar use case but multiple values to be selected in a field and then the dependent values should be populated in the another field. The values should  be from the xml file. I have tried using HTTP filter but I am not getting the appropriate X-path expression.  Can this be done using script based value set or X-path expression? if possible please guide on it.
I am missing something.
Below is the code: 

dojo.provide("org.example.workitems.providers.ProjectAutoModel");
dojo.require("com.ibm.team.workitem.api.common.connectors.HttpConnectorParameters");

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

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

    getFilteredValueSet: function(attributeId, workItem, context, filter) {
        
        var params= new HttpConnectorParameters();
        params.url= "https://xyz.com/ext/WorkItemXML/RCN.xml";
        params.xpath= "//xml/node/Project[contains('${ProjectName.value}',@name)]/CoreSRD[@name]";
        params.columnXpaths= ["./name"];
        params.columnIds= ["CoreSRD"];
        alert("in function!!");
        var connector= context.getDataConnector("HttpConnector");
        var values= connector.get(params);
        
        var result= [];
        while(values.hasNext()){
            var entry= values.next();
            var modelControl= entry.getById("CoreSRD");
            if (modelControl.indexOf(filter) > -1) {
                result.push(CoreSRD);
            }
        }
        
        return result;
    }
});
})();

Regards,
Deepali Nigade

One answer



permanent link
Donald Nong (14.5k414) | answered Apr 26 '16, 12:36 a.m.
A script-based value set should be quite easy to implement. Here is an example.
https://jazz.net/forum/questions/182739/script-based-dependent-list-shows-as-retrieving-for-ever
(in this example, "listb" depends on "lista")

Since in your case the attribute is multi-valued, you may consider using the "contains" operator rather than "equal to" in the conditions.

Comments
Deepali Deshmukh commented Apr 26 '16, 9:05 a.m. | edited Apr 26 '16, 9:10 a.m.

  Thank you Donald for your reply!!


In my case I want to fetch values from xml file. Projectname which is having values fetched from xml file.According to values in projectname, coresrd field should populate its values from xml. 



Donald Nong commented Apr 26 '16, 9:58 p.m.

Where did you get the code as the basis? The use of getFilteredValueSet looks very strange - I can only find its reference in this forum, but not in any other reliable or official resources. If you want to use HTTP filtered value set in the script based value set, check out Ralph's blog for an example.
https://jorgediazblog.wordpress.com/2012/06/27/work-item-customization-httpconector-and-oauth-in-rtc-4-0-for-oslc/


Deepali Deshmukh commented May 10 '16, 1:32 a.m.

 Hi Donald,

Thank you for the link, It really helped me. 
I have made changes in the script accordingly but its not working. 

It is not possible to have multi-select dependent values. I am trying to write script based value set for multi-select dependent values. I have attribute1 and attribute2 as enumeration list. when I select multiple values from attribute1 then in attribute3 should populate values from attribute2. As attribute2 is having all the dependent attributes of attribute1.

 I would appreciate if anyone can share the basic java script, that can read values from enumeration list. 

Regards,
Deepali Nigade

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.