Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to get attachment file name of a work item in a customized attribute

How can I get attachment file name of a work item in a customized attribute (calculated value or value set)? 
Do we have any way to do?

Background; A customer is using RELM to search RTC artifacts but attachment file name cannot be searched, so he is thinking to put the attachment filename in a customized attribute in a work item.

We are thinking to use HTTP Filtered Value Set Provider as one possible way, it is not successful to run yet. 

http://jorgediazblog.wordpress.com/2012/06/27/work-item-customization-httpconector-and-oauth-in-rtc-4-0-for-oslc/
https://jazz.net/wiki/bin/view/Main/DataSourceValueSetProviders#Tutorial_for_providing_a_custom
https://jazz.net/forum/questions/145566/rational-team-concert-use-httpconnectorparameters-on-calculated-value-script-based-custom-attribute
https://jazz.net/wiki/bin/view/Main/WorkItemAPIsForOSLCCM20#Introduction



0 votes


Accepted answer

Permanent link
 Hello,
I don't think this can be done: attachment(s) is not an attribute but a link.
You can use RTC Queries to search on attachments names, id:

Eric

Ralph Schoon selected this answer as the correct answer

0 votes

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

Permanent link
Takki,

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.

0 votes

Comments
In my testing, if I do the following, it works.
1. Customize attribute > Add Value set 'myValueSet’ / provider: HTTP Filtered Value Set Provider  >
    Configuration:
XML data source URL: https://<host>:9443/ccm/oslc/workitems/15/rtc_cm:com.ibm.team.workitem.linktype.attachment.attachment
 Row XPath : //Collection/Attachment
Column XPath expression: ./title
   Column Identifier : title
   Authentication method: OAuth

 2. Create an attribute ’TestField1’

3. Set the value set 'myValueSet’ in the attribute.
4. Add an editor presentation for the attribute with kind:picker.
 But If I add an editor presentation for the attribute with kind:string, it won't work because it seems the return value is array.

Also it works by following:

1. Customize attribute > Add Value set 'myValueSet3’ / provider: Script based value set  >

dojo.provide("com.example.ValueSetProvider3");
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.

showing 5 of 6 show 1 more comments

Permanent link

 hi 

this line of code

seems to be particular for a work item .
how to make it generic so that when we open a wok item its displays the attachment name attached to this work item.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 6,117

Question asked: Jul 03 '14, 2:57 a.m.

Question was seen: 6,636 times

Last updated: Oct 17 '18, 6:37 a.m.

Confirmation Cancel Confirm