It's all about the answers!

Ask a question

how to get the custom field attribute value in value set provider script


kesav d (1915) | asked Oct 17 '18, 7:31 a.m.

i am trying to display the name of attached files in a custom field(generic combo)  in a work item. 

so i created a value set script 
if i directly give the work item id it perfectly works , but how to make it generic so that when i open a work item its displays only the attached files belonging to the  opened work item ,

dojo.provide("com.example.ValueSetProvider33"); 
dojo.require("com.ibm.team.workitem.api.common.connectors.HttpConnectorParameters"); 
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() { 
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
    dojo.declare("com.example.ValueSetProvider33", null, { 
        getValueSet: function(attributeId, workItem, configuration){ 
                          { 
  var params= new com.ibm.team.workitem.api.common.connectors.HttpConnectorParameters(); 
 var ID = workItem.getValue(WorkItemAttributes.ID); 
        params.xpath= "//Collection/Attachment"; 
        
 
params.columnXpaths= ["./title"]; 
        params.columnIds= ["title"]; 
        params.ignoreInvalidCertificates=true; 
        params.useOAuth=true; 

        var connector= configuration.getDataConnector("HttpConnector"); 
        var values= connector.get(params); 
        var result= [];        
        while(values.hasNext()){  
            var entry= values.next();  
            var wiIDs= entry.getById("title");  
            result.push(wiIDs);  
        }  

        return result;  
    }  
   });  
})();

One answer



permanent link
Ralph Schoon (63.1k33646) | answered Oct 17 '18, 8:36 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

As of https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript the ID of the work item is WorkItemAttributes.ID or "id".


Comments
kesav d commented Oct 17 '18, 9:16 a.m.

 Ralph

WorkItemAttributes.ID only ...is it possible to retrieve any other custom field values in value set script and use it ..


Ralph Schoon commented Oct 17 '18, 9:42 a.m. | edited Oct 17 '18, 9:44 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

As described in the documentation I attached, in general it should be possible to use


getValue("IdOfTheAttribute");
getLabel("IdOfTheAttribute");

to access the Value and the display label of any work item attribute.

Read the documentation and make yourself aware that 
  1. Not all information you see in the work item UI is an attribute or based on an attribute
  2. There are unsupported attribute types. Any attribute type not listed in that documentation is likely not supported.


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.