It's all about the answers!

Ask a question

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


Taki Nakajo (1.1k2846) | asked Jul 03 '14, 2:57 a.m.
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



Accepted answer


permanent link
Eric Jodet (6.3k5111120) | answered Jul 03 '14, 4:43 a.m.
JAZZ DEVELOPER
 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

Comments
Taki Nakajo commented Jul 04 '14, 3:22 a.m.

 How to run a query in calculated value or value set?


Ralph Schoon commented Jul 04 '14, 3:38 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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
Ralph Schoon (63.2k33646) | answered Jul 03 '14, 4:49 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.

Comments
Taki Nakajo commented Jul 04 '14, 3:45 a.m.
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


Taki Nakajo commented Jul 04 '14, 3:45 a.m.

 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.


Taki Nakajo commented Jul 04 '14, 3:57 a.m.

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){



Taki Nakajo commented Jul 04 '14, 3:57 a.m.

        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= [];



1
Taki Nakajo commented Jul 04 '14, 3:58 a.m.

         while(values.hasNext()){ 
            var entry= values.next(); 
            var wiIDs= entry.getById("title"); 
            result.push(wiIDs); 
        } 

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


Taki Nakajo commented Jul 04 '14, 3:59 a.m.

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
kesav d (19117) | answered Oct 17 '18, 6:37 a.m.

 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.

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.