How to get attachment file name of a work item in a customized attribute
Accepted answer
Comments
How to run a query in calculated value or value set?
the only approach that might work is described here: http://jorgediazblog.wordpress.com/2012/06/27/work-item-customization-httpconector-and-oauth-in-rtc-4-0-for-oslc/
You would have to use REST/OSLC to access the query.
2 other answers
as far as I am aware you can't access the attachments collection from JavaScript in calculated value providers.
See: https://jazz.net/library/article/1093 Lab 5 especially the limitations.
You might be able to use tricks like the one provided by Jorge to succeed. Another way to proceed might be using Java as described here: https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/
JavaScript won't allow you to do this, I am sure.
Comments
2. Create an attribute ’TestField1’
Also it works by following:
dojo.require("com.ibm.team.workitem.api.common.connectors.HttpConnectorParameters");
(function() {
dojo.declare("com.example.ValueSetProvider3", null, {
getValueSet: function(attributeId, workItem, context){
var params= new com.ibm.team.workitem.api.common.connectors.HttpConnectorParameters();
params.url="https://vappwin2k8r2ja:9443/ccm/oslc/workitems/15/rtc_cm:com.ibm.team.workitem.linktype.attachment.attachment";
params.xpath= "//Collection/Attachment";
params.columnXpaths= ["./title"];
params.columnIds= ["title"];
params.ignoreInvalidCertificates=true;
params.useOAuth=true;
var connector= context.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;
}
});
})();
1 vote
But If I add an editor presentation for the attribute with kind:string instead, it won't work.